megha
megha

Reputation: 39

Unable to run scripts on IE using selenium grid

I am using selenium grid for running my scripts on different browsers on the same machine (hub and nodes are on same machine) . My code is running perfectly fine on firefox but is giving an error on Internet Explorer.

I have used the following command for configuring internet explorer :

java -jar selenium-server-standalone-2.25.0.jar -role webdriver -hub http://:4444/grid/register -port 5554 -browser platform=WINDOWS,ensureCleanSession=true,browserName="iexplore",version=8,ignoreProtectedModeSettings=true, javascriptEnable=true

I am using testng for running the scripts.

On running the test, Internet Explorer window opens but it displays "This is the initial start page of Webdriver" .The URL specified in test does not open and i get the following error :

org.openqa.selenium.UnhandledAlertException: Modal dialog present

Here is my code for setting the Desired Capabilities of IE :

if(browser.equalsIgnoreCase("iexplore")){
            System.out.println("iexplore");
            capability= DesiredCapabilities.internetExplorer();
            capability.setBrowserName("iexplore");
            capability.setVersion("8");
            capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
            capability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
        }

This is the code for opening the browser:

URL url = new URL("http://<hostname>:4444/wd/hub");
driver = new RemoteWebDriver(url, capability);
driver.get("http://google.com");

Please help in solving my issue. Thanks a lot

Upvotes: 0

Views: 2404

Answers (1)

Ubermensch_01
Ubermensch_01

Reputation: 1

I had a very similar issue. In my case it was an alert appearing while switching from http to https. Use the following statements to handle the alert:

WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.accept();

This did the trick for me. Hope this solution will help.

Upvotes: 0

Related Questions