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???
Asked
Active
Viewed 606 times
1 Answers
0
- 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?
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")));