I am trying to select the search element/button that is right at the top of the FaceBook app. Below is a snippet of my code:
List<WebElement> searchBox
= driverWait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(
By.xpath("//android.widget.EditText[contains(@resource-id, 'search_edit_text')]")));
I identified the resource ID by using UIAutomatorViewer. I’ve tried several other methods:
- Tried using
//*[...]
to look for the WebElement
.
- Tried using the fully-qualified resource ID:
com.facebook.katana:id/search_edit_text
.
- Tried using
By.id(...)
.
- Tried finding a parent higher up in the hierarchy tree to dig deeper for the search box.
- Tried searching for the text
Search
.
For each of the above methods, I have succeeded in locating and then clicking the search box, but I am unable to reproduce the result. In other words, Appium gives me inconsistent and unpredictable results. I can locate the search box some times, but other times, I get a timeout.
The appium server and the Java client do not throw any errors (except for time outs). I was wondering if any one has encountered the same problem. Is this a problem with the FB app, or am I doing something wrongly here? Are there other alternatives to achieve the same outcome?
Thanks!