// get all images and then select index
List [WebElement] pic= driver.findElements(By.className("//android.view.View"));
pic.get(1).click(); // click based on index of image
// use xpath indexing something like below
driver.findElement(By.xpath("(//android.view.View[@clickable=‘True’])[1]")).click();
driver.findElement(By.xpath("(//android.view.View[@clickable=‘True’])[2]")).click();
driver.findElement(By.xpath("(//android.view.View[@clickable=‘True’])[3]")).click();
driver.findElement(By.xpath("(//android.view.View[@clickable=‘True’])[4]")).click();
These are approaches may or may not work with u r set up.
Thank you for the help, I tried with your code it failed to run.
Below is the error
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Session ID: a899de06-f969-45c5-9af5-d2e6996dc98e
*** Element info: {Using=xpath, value=//android.widget.LinearLayout[1]/android.view.view[1][@clickable=‘True’]}
List img= driver.findElementsByName(“Photo (13 October 2015)”);
img.get(0).click ( );
Try with this code…hopefully it will work. If this code not worked then one more solution to install any third party gallery app from play store which will provide proper locators…
Or send me uiautomatorviewer dump. So we can also analysis locators.
Save image from uiautomatorviewer
It will generate two files. One snapshot and one dump file upload both.
If u want to click anything based on text present in ‘content desc’ below can be used. But it is more of hardcoding kind of thing. So using class name and xpath indexing is recommended because if image name is changed it will fail.
driver.findElement(By.AccessibilityID(“Photo (13 October 2015)”)).click().
driver.findElement(By.name(“Photo (13 October 2015)”)).click();
Hello,
some thing i want to do but i facing the issue while selecting the particular frame from gallery with the help of Ui viewer , using android device (lenovo k5).please help