driver.manage.wait(long timeout)
driver.manage.wait(long timeout)
is actually the java.lang.Object.wait()
method is from the java.lang.Object
Class
which causes the current thread to wait until either another thread invokes the notify()
method or the notifyAll()
method for this object or a specified amount of time has been elapsed. The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.
Declaration
The declaration of java.lang.Object.wait()
method is as follows :
public final void wait() throws InterruptedException
{
//code logic
}
Parameters
timeout - the maximum time to wait in milliseconds.
Return Value
This method does not return a value.
Usage
In the one argument version, interrupts and spurious wakeups are possible so this method should always be used in a loop as follows :
synchronized (obj) {
while (<condition does not hold>)
obj.wait();
... // Perform action appropriate to condition
}
This method should only be called by a thread that is the owner of this object's monitor.
Exception
Throws :
InterruptedException
: If another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
IllegalArgumentException
: If the value of timeout is negative.
IllegalMonitorStateException
: If the current thread is not the owner of the object's monitor.
Explicit Wait
Explicit Wait
is a code block you define, configure and implement for the WebDriver instance to wait for a certain condition to be met before proceeding for the next line of code. There are some methods that helps us to implement ExplicitWait that will wait only as long as required. WebDriverWait in combination with ExpectedCondition is one of the way ExplicitWait can be achieved.
You can find a detailed discussion on Explicit Wait
and it's implementation in the QA Replace implicit wait with explicit wait (selenium webdriver & java)
Answering this Question
obj.wait()
have no relation with WebDriverWait
. obj.wait()
deals with the internal logic at thread-level where as WebDriverWait
deals within the scope of HTML DOM
.