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.