Calabash supports identification of view both using xpath & CSS
Its confirmed in in here https://groups.google.com/forum/#!msg/calabash-ios/nubfmY-6jbM/aSoYtW9mT8cJ
But this information is missing in wiki page
Usage :
Using CSS to identify elements : query("webView css:'#header'")
for xpath identification replace css by xpath and specify the path.
In Calabash-IOS there is no way to get source of HTML page, Getting elements from page
can be bit tricky, There are several possibilities to get past this
check my video on this www.youtube.com/watch?v=w5rxvI3w2Ss
And also check below video
1) Use query("webView css:'*'") to get all associated elements on page then search for text you are looking at.
Index of results returned from query can be used to identify elements
Example:
res=query("webView css:'*'")
res[12] - could be the element you may want to verify
2) To verify if object is shown on screen .empty? can be very handy
res=query("view text:'SomeText'").empty? # res is false if element is present
use begin rescue block (in Ruby) to catch these exceptions and handle them
3) use regular expression
4) Using variables in search
5) Looping up and down until text found
end
or
7) to check first & last result of array
Its confirmed in in here https://groups.google.com/forum/#!msg/calabash-ios/nubfmY-6jbM/aSoYtW9mT8cJ
But this information is missing in wiki page
Usage :
Using CSS to identify elements : query("webView css:'#header'")
for xpath identification replace css by xpath and specify the path.
In Calabash-IOS there is no way to get source of HTML page, Getting elements from page
can be bit tricky, There are several possibilities to get past this
check my video on this www.youtube.com/watch?v=w5rxvI3w2Ss
And also check below video
1) Use query("webView css:'*'") to get all associated elements on page then search for text you are looking at.
Index of results returned from query can be used to identify elements
Example:
res=query("webView css:'*'")
res[12] - could be the element you may want to verify
2) To verify if object is shown on screen .empty? can be very handy
res=query("view text:'SomeText'").empty? # res is false if element is present
use begin rescue block (in Ruby) to catch these exceptions and handle them
3) use regular expression
query("view {text LIKE '*hello*'} ")
4) Using variables in search
text_to_check="hello"
query("view {text LIKE '*#{text_to_check}*'} ") 5) Looping up and down until text found
while(true)
begin
#check text found and click
rescue
#if there was any exception reported
scroll("view",:down)
end end
or
wait_poll(:until_exists => "label text:'Cell 22'", :timeout => 20) do scroll("tableView", :down) end
6)For converting case use upcase function
"hello".upcase
7) to check first & last result of array
arr=query("view {text LIKE '*#{text_to_check}*'} ")
arr.first
arr.last
No comments:
Post a Comment