Ruby Selenium unable to select image from android image gallery

我只是一个虾纸丫 提交于 2019-12-06 21:02:26

If you want the first image (ImageView) :

//*[@id='someId']/LinearView[1]/ImageView

Output :

<ImageView id="someImageId"/>

You can change the index in the LienarView array selection.

element = driver.find_element(:xpath, "//*[@id='someId']/LinearView[1]/ImageView")
p element
# <Selenium::WebDriver::Element:0x3eb6a9d8 id="{ea847fbe-7fc7-453b-97ea-74fbf325ddac}">

edit : You can also fetch all elements using find_elements() into an array and then, juste select the one you want :

elements = driver.find_elements(:xpath, '//ImageView')
p elements[1]
# <Selenium::WebDriver::Element:0x..f9bdc4412 id="{1f41fbd9-0a73-4fb2-9c98-44bb877e2388}">

You should be able to find it with Appium using:

//android.widget.ImageView[@id="someId"][1] 

or

//android.widget.GridView[@id="someId"]//android.widget.ImageView[@id="someId"][1]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!