I'm attempting to perform some automation of an Android app, using NGTest framework and UIAutomator.
The below is output from UI Automator - my XPath knowledge is not the hottest but I've attempted to select the parent of the Camera button using the following Java code:
WebElement e = driver.findElement(By.xpath("//android.widget.LinearLayout[@resource-id=com.instagram.android:id/tab_bar']"));
However this returns an exception:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
Could anyone guide me better on how to use XPath expressions to drill down into the tree from UIInspector? Should I be starting at the top and working my way down, or is it ok to try and grab children in this way?
I have also tried grabbing the camera icon directly using the bounds, but that didn't work either.
Attempted:
WebElement abc = driver.findElement(By.xpath ("//android.widget.ImageView[contains(@bounds,'[508,2119][571,2131]')']"));
abc.click();
I think you are missing a quote sign at the beginning of your resource-id value. You are using:
WebElement e = driver.findElement(By.xpath("//android.widget.LinearLayout[@resource-id=com.instagram.android:id/tab_bar']"));
And it should be:
WebElement e = driver.findElement(By.xpath("//android.widget.LinearLayout[@resource-id= 'com.instagram.android:id/tab_bar']"));
This element explorer can really help you locating the elements