0

Following tests is automated by using java and selenium-server-standalone-2.20.0.jar.

The test crashes with the error:

Page title is: cheese! - Google Search
Starting browserTest
2922 [main] INFO org.apache.http.impl.client.DefaultHttpClient - I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
2922 [main] INFO org.apache.http.impl.client.DefaultHttpClient - Retrying request
Exception in thread "main" org.openqa.selenium.UnhandledAlertException: Modal dialog present (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.20 seconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:04'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_24'
Driver info: driver.version: InternetExplorerDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:170)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:129)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:438)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:139)
    at org.openqa.selenium.ie.InternetExplorerDriver.setup(InternetExplorerDriver.java:91)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:48)
    at com.pwc.test.java.InternetExplorer7.browserTest(InternetExplorer7.java:34)
    at com.pwc.test.java.InternetExplorer7.main(InternetExplorer7.java:27)

Test Class:

    package com.pwc.test.java;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebDriverBackedSelenium;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.htmlunit.HtmlUnitDriver;
    import org.openqa.selenium.ie.InternetExplorerDriver;

    import com.thoughtworks.selenium.Selenium;

    public class InternetExplorer7 {
    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    WebDriver webDriver = new HtmlUnitDriver();
    webDriver.get("http://www.google.com");
    WebElement webElement = webDriver.findElement(By.name("q"));
    webElement.sendKeys("cheese!");
    webElement.submit();
    System.out.println("Page title is: "+webDriver.getTitle());
    browserTest();
}
    public static void browserTest() {
    System.out.println("Starting browserTest");
    String baseURL = "http://www.mail.yahoo.com";
    WebDriver driver = new InternetExplorerDriver();
    driver.get(baseURL);
    Selenium selenium = new WebDriverBackedSelenium(driver, baseURL);
    selenium.windowMaximize();
    WebElement username = driver.findElement(By.id("username"));
    WebElement password = driver.findElement(By.id("passwd"));
    WebElement signInButton = driver.findElement(By.id(".save"));
    username.sendKeys("myusername");
    password.sendKeys("magic");
    signInButton.click();
    driver.close();
    }
    }

I don't see any modal dialog when I launched the IE7/8 browser manually. What could be causing this?

2 Answers2

0

I was also getting the same exception on Firefox. I observed that the username and password fields were autocompleted because the option "Remember passwords for sites" was enabled in Firefox. So, while recording even if I erase the contents and enter, it would not record the data entered. I disabled the option and rerecorded my test case. Now, it works fine.

Hope it helps.

Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
0

You may take a screenshot by webDriver to see the modal dialog when this Exception occurs.

Pazonec
  • 1,549
  • 1
  • 11
  • 35
  • http://stackoverflow.com/questions/3422262/take-a-screenshot-with-selenium-webdriver This post explains how to take a screenshot. Are you sure that you have no alerts or js errors? – Pazonec Mar 09 '12 at 08:46