While using IE for automation using Selenium Webdriver, I am able to open the URL but finding the element on that page is throwing the following exception:
org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window (WARNING: The server did not provide any stacktrace information)
I have tried the driver.switchTo.window()
method but it's not working.
I have searched it for hours and I am not getting anywhere.
Here's the code:
public static Selenium selenium;
public static void main(String args[]) {
try {
System.setProperty(
"webdriver.ie.driver",
"D:\\Driver\\IEDriverServer_Win32_2.32.3_latest\\IEDriverServer.exe");
DesiredCapabilities capab = DesiredCapabilities.internetExplorer();
capab.setCapability(
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
true);
WebDriver driver = new InternetExplorerDriver(capab);
driver.get("http://www.google.com");
driver.findElement(By.xpath(".//*[@id='addlang']/a[1]")).click();
} catch (Exception e) {
e.printStackTrace();
}
}