Hi Folks,
I am getting stuck at executing a loop .My scenario is like i am tapping on bookmark present over the screen .so i am using below code for that ,
List listAllSessionsNames=driver.findElements(By.xpath("//UIAApplication[1]/UIAWindow[2]/UIATableView[1]/UIATableCell[*]//descendant::UIAButton"));
for(MobileElement eachSessionName:listAllSessionsNames) {
try{
if(!eachSessionName.isDisplayed()){
// initIPHONE.swipeDown();
eachSessionName.click();
}
else{
initIPHONE.swipeDown();
eachSessionName.click();
}
}
catch(WebDriverException e){
e.printStackTrace();
}
}
Now, problem is button is getting tapped until buttons are visible on screen but getting webdriverexception after tapping on same button .
the whole size of the table cell over the screen are 10 but this code can work for 5 .
Please help .
After each swipe you should reassign list of elements.
yes i did @Aleksei but its tapping on each button again and again . Plese have a look at the post code .
List listAllSessionsNames=driver.findElements(By.xpath("//UIAApplication[1]/UIAWindow[2]/UIATableView[1]/UIATableCell[*]//descendant::UIAButton"));
for(MobileElement eachSessionName:listAllSessionsNames) {
try{
if(!eachSessionName.isDisplayed()){
initIPHONE.swipeDown();
List<MobileElement> listAllSessionsNames1=driver.findElements(By.xpath("//UIAApplication[1]/UIAWindow[2]/UIATableView[1]/UIATableCell[*]//descendant::UIAButton"));
for(MobileElement eachButton:listAllSessionsNames1){
if(eachButton.isDisplayed()){
eachButton.click();
System.out.println("TEST TAPS ON EACH BOOKMARK OF THE SESSION "+"STEP PASS");
Reporter.log("TEST TAPS ON EACH BOOKMARK OF THE SESSION "+"STEP PASS");
}}
}
else{
//initIPHONE.swipeDown();
// eachSessionName.swipe(SwipeElementDirection.DOWN, 3000);
eachSessionName.click();
System.out.println("TEST TAPS ON EACH BOOKMARK OF THE SESSION "+"STEP PASS");
Reporter.log("TEST TAPS ON EACH BOOKMARK OF THE SESSION "+"STEP PASS");
}
}
catch(WebDriverException e){
e.printStackTrace();
}
}
can you post screenshots of what is needed to do in test.