硒黄瓜中运行文件的初始化错误

时间:2018-05-09 10:42:59

标签: java selenium cucumber

下面给出了3个不同的文件详细信息 - 功能文件/跑步者文件和步骤定义文件

package Runner;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features="Features")
public class testrunner {

}


package stepdef;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class smoketest {

    WebDriver driver;
    @Given("^Open chrome and start application$")
    public void Open_chrome_and_start_application() throws Throwable{
        driver=new FirefoxDriver();
        driver.manage().window().maximize();
        driver.get("https://www.facebook.com");
    }
    @When("^I enter valid username and valid password$")
public void I_enter_valid_username_and_valid_password() throws Throwable{

    }
    @Then("^User should be login sucessfully$")
public void User_should_be_login_sucessfully() throws Throwable{

    }

}
{{1}}

1 个答案:

答案 0 :(得分:1)

请检查功能文件路径。尝试使用功能文件的绝对路径,它区分大小写。因此,请检查功能文件名称。例如,如果将要素文件保留在项目的“功能”文件夹下。

请尝试以下代码。

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features="classpath:Features")
public class testrunner {

}

并且您正在为步骤定义设置胶水路径。即使您解决了上述错误,也会得到步骤定义未找到错误。除非或直到你将类保留在项目目录中。

相关问题