I have a UITableView which contains about 50 elements. At any point only 6 of them are visible on screen. I want to select a cell which is not added to table view or say I need to select 25th item from the data list.
Now I am using this method for clicking a cell in tableview
wait.until(ExpectedConditions.visibilityOf(driver.findElementByAccessibilityId(element))).click();
But its not working as the 25th element is not added to the view yet. Please note that I am adding the accessibility identifier for the table view cell dynamically within the code.
How can I make this work?
***** Added more details******
I have the table view cell displaying two text views. Currency Short Name and Currency Long Name.
Consider the example
GBP
Great Britain Pounds
Now the accessibility Identifier for that tableview cell is set as GBP. Now I tried
driver.scrollTo("GBP") and driver.scrollTo("Great Britain Pounds")
Both didnt work. I am getting an error message
A element could not be located on the page using the Search parameter
Thanks.
String ReqN = "Your required string";
boolean flag = true;
while (flag) {
for (i=1;i<=6;i++) {
String GetN = driver.findElement(By.xpath("//android.widget.HorizontalScrollView/android.widget.LinearLayout[" + i + "]")).getText();
if (GetN.equals(ReqN)) {
flag = false;
System.out.println("Your result found");
}
}
if (flag) {
driver.swipe(145, 765, 145, 180, 3000);
}
}
String ReqN :: Your predefined string
String GetN :: Text get for each element [1 to 6 which we get by for loop ]
So it get text & match for first six elements if your predefined text not found then it swipe from given axes [ which is 6th element to 1st element ] ..so you will get new six element & loop will be executed again.
Ref. Image Elements & X,Y points
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With