1

I am getting stuck at executing a loop. My scenario is: I am tapping on bookmark present over the screen.

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();

    }     
  }

The problem is that the button is getting tapped until buttons are visible on screen but getting webdriverexception after tapping on the same button. The whole size of the table cell over the screen is 10 but this code can work for 5. Please help.

5
  • 1
    Q1- What exception are you getting. Q-2 :Clear the last line (regarding the 10, 5). That is confusing. – demouser123 Jan 5 '16 at 11:48
  • i am getting WebDriverException .but this issue is resolved to some extent by re assigning the list after swipe . Currently after first swipe ,buttons are tapped multiple times that is weird . – Ranjan Gupta Jan 5 '16 at 12:20
  • Then update you question with the latest information. That would be good – demouser123 Jan 5 '16 at 12:48
  • What is returns when you print listAllSessionsNames.size() ? – Helping Hands Jan 5 '16 at 13:46
  • It was returned me exact no of values and that was 10. – Ranjan Gupta Jan 5 '16 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.