In this activity, I have 5 Text Views with same resource-id.
How can I select the first one with Java client Appium automation?
Is there any way to use resource-id and index combination.
I expect a non xpath strategy if available to select that.
In this activity, I have 5 Text Views with same resource-id.
How can I select the first one with Java client Appium automation?
Is there any way to use resource-id and index combination.
I expect a non xpath strategy if available to select that.
<iList> iWebElement
get all the elemants which have id
name as Normal_view
Text Views.
below is a sample ,but in c#
IList<IWebElement> sidemenuList = elm2.Modules.FindElements(By.TagName("li"));
Thread.Sleep(3000);
sidemenuList[4].Click();
It depends what you are looking for, will you need to use all 5 textViews in your tests or will you only need the 3rd and never use others?
For the former create a list of webElements, then iterate through the list depending on which element you need at the moment. The syntax is pretty easy:
List<WebElement> elementsList = driver.findElements("your locator strategy")
elementsList.get(2).click; //this will click on the highlighted element from your screenshot
For the latter: 1. use either an xpath or UiAutomator locator (both have options to get to a specific element) 2. use page factory and @FindBys annotation to get a chained locator. 3. if the element you're looking for has a unique id - then you can locate it with id, else - don't. If you absolutely want to use id locators, then ask your developers to add unique ids to all elements that you need