I'm using selenium 3.0.1 and java client library 3.0.1. I'm using the following code.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class UserActions2 {
public static void main(String[] args) throws InterruptedException
{
System.setProperty("webdriver.gecko.driver","geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.navigate().to("https://www.google.co.in/");
driver.manage().window().maximize();
String str = driver.getCurrentUrl();
System.out.println("The current URL is " + str);
}
}
And getting the error after FireFox launch
Exception in thread "main" java.lang.IllegalMonitorStateException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at Actions.UserActions2.main(UserActions2.java:20)
I have no clue for this error. I checked online, But there is No help.
1 Answer 1
I have run given above code and its running fine.
Mostly here might have configuration problem.
Working configuration of my system :
JDK 1.8 installed and added JAVA_HOME env variable and in path. Refer
Selenium Webdriver version 3.0 + Download
Firefox latest version (v50 or more) Download and Install
Download latest Geckodriver from Here. And put is in root directory of your project. If code is require path of Geckodriver then follow this
My Working code :
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class UserActions2
{
public static void main(String[] args)
{
try
{
System.setProperty("webdriver.gecko.driver", "geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.navigate().to("https://www.google.co.in/");
driver.manage().window().maximize();
String str = driver.getCurrentUrl();
System.out.println("The current URL is " + str);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
-
The problem existed because I included geckodriver.exe in the referenced libraries of the project. Anyway, I fixed the problem.raghu– raghu2017年02月10日 09:02:30 +00:00Commented Feb 10, 2017 at 9:02
String str = driver.getCurrentUrl();
so that the webpage is loaded.