硒/黄瓜在文件夹迁移后没有看到步骤定义



用于此的依赖项:

黄瓜核-1.2.4cucumber.html-0.2.3Cucumber-Java-1.2.4黄瓜-Junit-1.2.4Junit-4.11Gherkin-2.12.2cucumber-jvm-deps-1.0.3

我最近清理了依赖关系文件夹的结构,并认为我可能放错了一些东西,但是我的问题是一个实例化问题,因为我似乎在黄瓜方面连续将鸭子拿到。这是堆栈跟踪:

cucumber.runtime.CucumberException: Failed to instantiate class cucumber.feature.LoginandMeetingCreation
at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:46)
at cucumber.runtime.java.DefaultJavaObjectFactory.getInstance(DefaultJavaObjectFactory.java:32)
at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:38)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:299)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.runtime.Runtime.run(Runtime.java:121)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:40)
    ... 11 more
Caused by: java.lang.NullPointerException
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:770)
    at org.openqa.selenium.support.ui.FluentWait.<init>(FluentWait.java:96)
    at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:71)
    at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:45)
    at cucumber.feature.LoginandMeetingCreation.<init>(LoginandMeetingCreation.java:19)
    ... 16 more

这是我的黄瓜跑者,它设置了功能文件,但从未执行胶水命令。我的软件包cucumber.feature包含我的步骤定义文件loginandMeetingCreation.java文件:

    package cucumberInitialization;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {"pretty" , "json:target/cucumber.json"},
        features = {"src/cucumber/"},
        monochrome = true,
        glue = {"cucumber.feature"}

        )
public class cucumberRunner {
}

具有步骤的功能文件:

Feature: Create a meeting and fill in the necessary text fields
Scenario: As a user, login and create a meeting
    Given I navigated to the site
    When I login and select an org
    Then Create a meeting

最后我的步骤定义:

package cucumber.feature;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class LoginandMeetingCreation {
    WebDriver chromeDriver = null;
    WebDriver ieDriver = null;

    //open IE and Chrome browsers and go to Website
    @Given("^I navigated to the site$")
    public void navigateToWebsite() throws Throwable{
    throw new PendingException();   
    }
    //login users
    @When("^I login and select an org$")
    public void userLogin() throws Throwable{
    throw new PendingException();
    }
    @Then("^Create a meeting$")
    public void meetingCreation() throws Throwable{
        throw new PendingException();
    }
}

有任何建议?

谢谢galexmes。

你是对的,我忘记了我删除了大量数量,它在我身上突然我正在创建一个无法接受无效价值的对象。当我撰写WebDriverWait wait = new WebDriverWait(ieDriver, 5); IEDRIVER时,它是null,这会导致NPE。从非零值创建IEDRIVER对象后,执行了预期的行为。

最新更新