INFO:处理请求时捕获的I / O异常(java.net.SocketException):软件导致连接中止:recv失败

时间:2013-11-18 17:02:28

标签: java eclipse selenium

尝试通过selenium webdriver在eclipse上运行我的测试用例。它仅适用于Firefox驱动程序和Chrome驱动程序,但它不适用于IE驱动程序。控制台中的错误显示为:

INFO:处理请求时捕获的I / O异常(java.net.SocketException):软件导致连接中止:recv失败

2013年11月18日下午4:26:01 org.apache.http.impl.client.DefaultRequestDirector tryExecute

信息:正在重试请求

2013年11月18日下午4:26:10 org.apache.http.impl.client.DefaultRequestDirector tryExecute

INFO:处理请求时捕获的I / O异常(java.net.SocketException):连接重置 2013年11月18日下午4:26:10 org.apache.http.impl.client.DefaultRequestDirector tryExecute INFO:重试请求 -

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;
    }
}
}

0 个答案:

没有答案