-1

I have various methods in my code in which i need to use WebDriverWait.Usually we declare it in main method like: WebDriverWait mywait= new WebDriverWait(driver,25). While using junit in selenium there is no main method,so how can i use WebDriverWait for webelements in various methods in my code???

1 Answers1

0
  1. Way you can call your JUNIt function from main.

here some help how to : How do I run JUnit tests from inside my java application?

  1. or you can simply add Thread.sleep(millisecodns)

    try { Thread.sleep(100); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); }

It must works in JAVA (Eclipse) But you can also use ( i think better for testing: ):

FluentWait fluentWait = new FluentWait<>(webDriver) {
  .withTimeout(30, TimeUnit.SECONDS)
  .pollingEvery(200, TimeUnit.MILLISECONDS);
  .ignoring(NoSuchElementException.class);
}

WebElement element = (new WebDriverWait(driver, 10))
   .until(ExpectedConditions.elementToBeClickable(By.id("someid")));

source : https://stackoverflow.com/a/20903328/2147581

Community
  • 1
  • 1
SüniÚr
  • 714
  • 1
  • 12
  • 29