0

Tried to run my test cases on eclipse through the selenium webdriver. It only works on Firefox driver and Chrome driver but it doesn't work on IE driver. It says in the console Started InternetExplorerDriver server but it doesn't open the window. Here is the code I'm trying to run.

package com.example.tests;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.Select;

public class MaggiesSanityTesting {
    private WebDriver driver;
    private String baseUrl;
    private boolean acceptNextAlert = true;
    private StringBuffer verificationErrors = new StringBuffer();

    @Before
    public void setUp2() throws Exception {
        driver = new InternetExplorerDriver();
        baseUrl = "http://maggies.latestcreativework.com/";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    @Test
    public void testUntitled() throws Exception {
        driver.get(baseUrl + "/");
        driver.findElement(By.linkText("HOW MAGGIE’S CAN HELP")).click();
        driver.findElement(By.cssSelector("li.sibling")).click();
        driver.findElement(By.linkText("OUR CENTRES")).click();
        driver.findElement(By.linkText("HOW YOU CAN HELP")).click();
        driver.findElement(By.linkText("ABOUT MAGGIE’S")).click();
        driver.findElement(By.cssSelector("img[alt=\"Maggie's Logo\"]")).click();
    }

    @After
    public void tearDown() throws Exception {
        driver.quit();
        String verificationErrorString = verificationErrors.toString();
        if (!"".equals(verificationErrorString)) {
            fail(verificationErrorString);
        }
    }

    private boolean isElementPresent(By by) {
        try {
            driver.findElement(by);
            return true;
        } catch (NoSuchElementException e) {
            return false;
        }
    }

    private boolean isAlertPresent() {
        try {
            driver.switchTo().alert();
            return true;
        } catch (NoAlertPresentException e) {
          return false;
        }
    }

    private String closeAlertAndGetItsText() {
        try {
            Alert alert = driver.switchTo().alert();
            String alertText = alert.getText();
            if (acceptNextAlert) {
                alert.accept();
            } else {
                alert.dismiss();
            }
            return alertText;
        } finally {
            acceptNextAlert = true;
        }
    }
}

To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode"

I have just tried it but it's throwing this error in the console:

INFO: I/O exception (java.net.SocketException) caught when processing request: Software caused connection abort: recv failed Nov 18, 2013 4:26:01 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request Nov 18, 2013 4:26:10 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset Nov 18, 2013 4:26:10 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request.

Also, it's required to set the Protected Mode settings of IE to the correct values.

I have done this but it's not running my test case on IE still. It just opens up the base URL but doesn't actually run the test case. Any help will be appreciated.

kenorb
  • 155,785
  • 88
  • 678
  • 743
user3005244
  • 11
  • 1
  • 2
  • What version of the IEDriver? What version of IE? Have you set the Protected Mode settings in IE correctly? – Arran Nov 18 '13 at 15:49
  • Thanks. I'm using "IEDriverServer.exe" for Selenium tests. I am running IE10. The Protected Mode settings in IE is set as default. – user3005244 Nov 18 '13 at 16:07
  • 1
    "Default" means what? As part of setting up IE properly, to be "ready" for automated testing, you need to ensure all the protected mode settings are on/off for each individual zone. Have you done this? https://code.google.com/p/selenium/wiki/InternetExplorerDriver#Required_Configuration – Arran Nov 18 '13 at 16:08
  • I'm not quite sure how to do this. Any form of help will be substantial and appreciated. Thanks – user3005244 Nov 18 '13 at 16:13
  • The page I linked to tells you how to do it: `To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".` ...nothing more than that. Also, a bit more visual: http://www.sevenforums.com/tutorials/63141-internet-explorer-protected-mode-turn-off.html ......also ensure you are using the 32bit IEDriver. – Arran Nov 18 '13 at 16:16
  • Thanks. I have just tried it but it's throwing this error in the console: INFO: I/O exception (java.net.SocketException) caught when processing request: Software caused connection abort: recv failed Nov 18, 2013 4:26:01 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute INFO: Retrying request Nov 18, 2013 4:26:10 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute INFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset Nov 18, 2013 4:26:10 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute INFO: Retrying request – user3005244 Nov 18 '13 at 16:27
  • As a result it opens the page but doesn't run the test case – user3005244 Nov 18 '13 at 16:28
  • Please add this information to the question above, so it's readable. – Aaron Digulla Nov 18 '13 at 16:32
  • @user3005244: That's not an error message; it's informational. It's a [red herring](http://jimevansmusic.blogspot.com/2012/12/seeing-info-messages-in-log-does-not.html) with respect to diagnosing your problem. Also, it's **required** to set the [Protected Mode settings of IE](http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html) to the correct values. – JimEvans Nov 18 '13 at 18:59
  • I have done this but it's not running my test case on IE still. It just opens up the base URL but doesn't actually run the test case. Any help will be appreciated. Thanks – user3005244 Nov 19 '13 at 10:16
  • Possible duplicate of [apache http client org.apache.http.NoHttpResponseException: The target server failed to respond](https://stackoverflow.com/questions/18237486/apache-http-client-org-apache-http-nohttpresponseexception-the-target-server-fa) – kenorb Oct 22 '17 at 22:22

0 Answers0