I tried using wait function too that to showed error.
CodePudding user response:
Thread
is part of another library, not part of the Selenium plugin.
Add this line to your code and compile:
import java.lang.Thread;
CodePudding user response:
This is not an actual error. It's just an indication that you have to allow the InterruptedException to propagate up the call stack, as an example, by adding a throws
clause to the method in turn and letting the caller determine how to handle the interrupt. This can involve our not catching the exception or catching and rethrowing it.
There are some methods in Java that throws InterruptedException. Some examples are:
Object class:
Thread.sleep()
Thread.join()
wait()
BlockingQueue:
put()
take()
Solution
To add the throws
clause you need to modify the code block as follows:
public static void main() throws InterruptedException {
// some lines
Thread.sleep(1000);
// remaining lines
}