Spring Boot - 无法用硒设置黄瓜

时间:2017-05-09 19:31:28

标签: java spring selenium spring-boot

在我的Spring启动应用程序中,我想用硒设置黄瓜测试。但是,当我运行测试时,响应是一个空页面,似乎连接被拒绝。我的代码如下。我做错了什么?

CucumberTest.java

@RunWith(Cucumber.class)
@WebAppConfiguration
@CucumberOptions(features = "src/test/java/cucumber/features")
public class CucumberTest {

}

DashboardLoginStep.java

@ContextConfiguration(classes = Application.class, loader = 
                SpringApplicationContextLoader.class)
@IntegrationTest
@WebAppConfiguration
public class DashboardLoginStep {

    private WebDriver driver;

    @Before
    public void setUp() {
        driver = new HtmlUnitDriver(true);
    }

    @Given("^the politician is in the login page$")
    public void isInLoginPage() {
        System.out.println(driver.getPageSource());
        driver.get("http://localhost:8090/");
        driver.navigate().to("http://localhost:8090/");
        System.out.println(driver.getPageSource());
        System.out.println("The politician is in the login page");
    }

    @Then("^introduces his credentials, \"(.+)\" and \"(.+)\" into the login 
    form$")
    public void insertCredentials(String mail, String psw) {
        System.out.println("Introduces his credentials");
    }

    @When("^he pushes the \"Log in\" button$")
    public void pushLogIn() {
        System.out.println("He pushes the login button");
    }

    @And("^he gets redirected to the dashboard view$")
    public void isInDashboard() {
        System.out.println("He gets redirected to the dashboard view");
    }
}

打印件在控制台上成功显示,这意味着黄瓜步骤正在执行,但是selenium部分返回一个空页面并且连接被中止。

谢谢。

0 个答案:

没有答案