I’m looking at an option list on an android device
The options code looks like this:
<div class = "addMode">
<label for ="activityType">Activity Type</label>
<div class="dataRow activityType">
<select id="activityType" class="valid">
<option value ="1" selected="selected">Appointment</option>
<option value ="2">Call</option>
<option value ="3">To-Do</option>
</select>
</div>
<div>
At first I tried xpath:
el = @d.find_elements(:xpath, "//*[@id='activityType']/option")
el.each do |t|
if t.text() == 'Call' then
t.click
break
end
end
This works to select the ‘Call’ activity from the pop-up menu, however, as soon as it is selected it exits from the current page, and returns to the calling page.
I then tried:
el = @d.find_element(:id, "activityType")
el.click
el_opt = el.find_elements(:tag_name, "option")
el_opt.each.do |t|
if t.text() == 'Call' then
t.click
break
end
end
This also had the same result of making the selection, and then exiting the screen
Then it was on to:
opt = Selenium::WebDriver::Support::Select.new(@d.find_element(:xpath, "//*[@id='activityType']"))
opt.select_by(:text, "Call")
This also made the selection, and then exited the page
I then thought, i might be able to use the Touch action
I’m still new to Ruby and I’m most likely reading the API for TouchScreen incorrectly
I tried the following:
TapObject = Selenium::WebDriver::TouchScreen.new(@d.find_element(:id, "activityType"))
el = @driver.find_element(:id, "activityType")
el_opt = el.find_elements(:tag_name, "option")
el_opt.each do |t|
if t.text() == "Call" then
TapObject.single_tap(t)
end
end
I get an undefined method ‘touchSingleTap’ error for this
Has anyone run into this problem, or know of a way to click/tap on a selection on a mobile device without it exiting the current page?
Thanks,
Jeff
Looks like the solution to this was really simple.
Instead of trying to click the element from the pop-up list, just use send keys instead.
Thanks,
Jeff