【问题标题】:Initialization Error on running file in selenium cucumber硒黄瓜中运行文件的初始化错误
【发布时间】:2018-05-09 10:42:58
【问题描述】:

下面给出了 3 个不同的文件详细信息-Feature 文件/运行器文件和 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{

    }

}

【问题讨论】:

  • 可以添加异常堆栈跟踪吗?

标签: java selenium cucumber


【解决方案1】:

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

试试下面的代码。

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

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

}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-07
    • 2017-04-16
    • 2010-11-18
    • 1970-01-01
    相关资源
    最近更新 更多