Gourav Sinha
Gourav Sinha

Reputation: 315

No window found (WARNING: The server did not provide any stacktrace information)

What I want to do is switching to a new popup child window when I click a link. But I am not able to do so as the parent window closes when I click that link. Sometime it works when I use Thread.sleep(time) but not always and I got the exception Exception in thread "main" org.openqa.selenium.NoSuchWindowException: No window found (WARNING: The server did not provide any stacktrace information).

It is also not working with implicit and explicit wait. Please suggest a better solution which work always.

JavascriptExecutor je3 = (JavascriptExecutor) driver;
       je3.executeScript("arguments[0].click();",driver.findElement(By.xpath("//a[@ardbn='Yes__c']/div")));
       //driver.findElement(By.xpath("//a[@ardbn='Yes__c']/div")).click();
       
       driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
       
       while(driver.getWindowHandles().size() != (size+1)){    }
       
       driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
              
       handles =  driver.getWindowHandles();
       
       for(String windowHandle  : handles)
           {
           
    	   if(!windowHandle.equals(handle))
           {
           driver.switchTo().window(windowHandle);
           
           }
    	   
           }

Upvotes: 1

Views: 797

Answers (1)

Anton Angelov
Anton Angelov

Reputation: 1713

You can try the following code during the initialization:

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();

capabilities.setCapability(CapabilityType.BROWSER_NAME, "IE");

capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);

capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);

System.setProperty("webdriver.ie.driver","C://MavenTest//driver//IEDriverServer.exe");

driver = new InternetExplorerDriver();

Upvotes: 1

Related Questions