driver.wait() throws IllegalMonitorStateException
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
is the best solution. Else, you have surround the driver.wait
by synchronize block
You can only wait
on an object if you've acquired the lock for it using synchronized
.
I don't know whether you're meant to use wait
using WebDriver - if you are, you'd need something like:
synchronized (driver)
{
driver.wait();
}
However, if you're waiting for something to occur, it's more likely that there's an alternative method you're meant to be using. Perhaps WebDriverWait
?
I hope this helps you
driver.manage().timeouts().implicitlyWait(long time, java.util.concurrent.TimeUnit unit);
OR
WebDriverWait wait = new WebDriverWait(driver, long timeOutInSeconds);
WebElement element = wait.until(presenceOfElementLocated(org.openqa.selenium.By locator));
Please note that I have not executed this code as I don't have webdriver but I wrote this after referring to javadocs.
Please refer javadocs for more details on this.