Ruby Selenium no puede seleccionar la imagen de la galería de imágenes de Android

I am trying to select an image from Android image galley grid view. This grid view has ImageView for every image. Every ImageView has id.

So when i am trying to get by //ImageView[@id="someId"][1] o por //GridView[@id="someId"]//ImageView[@id="someId"][1], it does not find it.

How can I select image from gallery using Selenium webdriver in ruby.


<GridView id = "someId">
        <ImageView id = "someImageId"></ImageView>
        <ImageView id = "someImageId"></ImageView>
        <ImageView id = "someImageId"></ImageView>
        <ImageView id = "someImageId"></ImageView>

EDITAR As Uiautomator cannot select the thumbnails in Gallery, I tried to pick image using relative co ordinates but this is giving an error.

Is any one has done this? I need to select image from android gallery.

preguntado el 28 de mayo de 14 a las 11:05

driver.find_element(:id, "someId") Deberia trabajar. -

Yes I tried that too but not working. Also there are more than one imageview in container, so using this I can't get first ImageView -

Need to see the HTML then.. -

2 Respuestas

If you want the first image (ImageView):



<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}">

contestado el 28 de mayo de 14 a las 13:05

Thanks, I tried all this before. But can't get image from gallery container. May be this is an issue with getting image from gallery container for an Appium. - User16119012

Weird, it's working on my browser with your XML file (webdriver). Are you using the AndroidDriver ? - cebolla

Hmm, this is the problem with Appium, Appium cannot select the thumbnails in Gallery. - User16119012

You should be able to find it with Appium using:




Respondido el 06 de junio de 14 a las 04:06

This does not work either. I resolved this issue by another way. - User16119012

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.