Getting java.lang.IllegalMonitorStateException while using the method wait. please let me know why?

Hi,

I have written a small script where I am using the wait method. I am getting the below error. Please help me in solving this.

 

Error:

java.lang.IllegalMonitorStateException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Unknown Source)
at automationFramework.TC.main(TC.java:32)

 

My Scirpt:

package automationFramework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
//private static final By Email = null;
public abstract class TC implements WebDriver {

public static void main(String[] args) throws InterruptedException {
String exePath = “C:\\Users\\Pratilipi\\Downloads\\chromedriver_win32\\chromedriver.exe”;
System.setProperty(“webdriver.chrome.driver”, exePath);
WebDriver driver = new ChromeDriver();
String orgurl = “https://www.facebook.com/”;
driver.get(orgurl);
// driver.switchTo().frame(“UWPIFrame”);
// driver.wait(5);
String titlename = driver.getTitle();
int len=titlename.length();
String url = driver.getCurrentUrl();
System.out.println(“Page name is “+titlename);
System.out.println(“Page titile length is “+len);
System.out.println(“Page original url is “+orgurl);
System.out.println(“Page url is “+url);
if (orgurl.equals(url))
{
System.out.println(“Correct page opened”);
}
else
System.out.println(“Not Correct”);
// By ele = Email;
driver.wait();
driver.findElement(By.id(“Email or Phone”)).sendKeys(“<username entered>”);
// driver.navigate().to(“https://www.google.co.in”);

// driver.quit();

}
}

Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.