我想选择Android的图像厨房网格视图的图像。此网格视图有的ImageView
的每张图片。每个的ImageView
的ID。
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.
所以,当我试图让 //的ImageView [@ ID =someId] [1]
或 // GridView控件[ @ ID =someId] // ImageView的[@ ID =someId] [1]
,它没有找到它。
So when i am trying to get by //ImageView[@id="someId"][1]
or by //GridView[@id="someId"]//ImageView[@id="someId"][1]
, it does not find it.
如何从图库中选择使用图像在Ruby中硒的webdriver
。
How can I select image from gallery using Selenium webdriver in ruby
.
编辑:
<GridView id = "someId">
<LinearView>
<ImageView id = "someImageId"></ImageView>
</LinearView>
<LinearView>
<ImageView id = "someImageId"></ImageView>
</LinearView>
<LinearView>
<ImageView id = "someImageId"></ImageView>
</LinearView>
<LinearView>
<ImageView id = "someImageId"></ImageView>
</LinearView>
</GridView>
修改由于Uiautomator不能选择在画廊缩略图,我试图使用相对坐标共同挑选形象,这是给了一个错误。
EDIT As Uiautomator cannot select the thumbnails in Gallery, I tried to pick image using relative co ordinates but this is giving an error.
时的任何一个人这样做呢?我需要从Android图库中选择图片。
Is any one has done this? I need to select image from android gallery.
如果你想第一个图像(的ImageView
)
If you want the first image (ImageView
) :
//*[@id='someId']/LinearView[1]/ImageView
输出:
<ImageView id="someImageId"/>
您可以更改 LienarView
阵列选择的索引。
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}">
编辑:您也可以使用 find_elements()
到一个数组中获取所有的元素,然后,中庸之道选择一个你想要的:
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}">