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



下面给出了3个不同的文件详细信息-功能文件/运行器文件和Step Def文件

@featureTest Feature: Test Facbook smoke Scenario
@Scenario1   Scenario: Test Login with valid Credentials
Given Open chrome and start application
When I enter valid username and valid password
Then User should be login sucessfully

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

请检查功能文件路径。 尝试使用功能文件的绝对路径,它区分大小写。因此,请检查功能文件名是否相同。例如,如果将功能文件保存在项目的"功能"文件夹下。

请尝试以下代码。

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features="classpath:Features")
public class testrunner {
}

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

最新更新