1
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class Test1 {

    public static void main(String[] args) throws InterruptedException {
          // TODO Auto-generated method stub
          System.setProperty("webdriver.chrome.driver","C://chromedriver_win32//chromedriver.exe");
          WebDriver driver= new ChromeDriver();
          driver.get("http://qaclickacademy.com/practice.php");
          List<WebElement> elements = driver.findElements(By.xpath("//input[@type= 'checkbox']"));
          System.out.println(Integer.toString(elements.size()));

          for(WebElement el:elements)
          {
                el.click();
          }
    }
}
7
  • Can you try by providing wait statement.
    – shanila
    Commented Jan 19, 2019 at 12:11
  • I have used wait but still the program is going timeout exception. Commented Jan 20, 2019 at 4:26
  • Code looks good, providing wait as suggested by Shanila should help, if not please share the exception stack.
    – Shamanth
    Commented Jan 21, 2019 at 3:45
  • There could be a potential issue in the click statement as you are performing them in a loop. After performing the initial events, the state of the rest of the elements might be changing. So please be careful while performing webdriver events in loop. Commented Jan 21, 2019 at 5:32
  • Probably your browser was updated and you need to update your webdriver?
    – Alexey R.
    Commented Jan 21, 2019 at 12:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.