Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Selenium/Cucumber在文件夹迁移后未看到步骤定义_Java_Selenium_Junit_Cucumber - Fatal编程技术网

Java Selenium/Cucumber在文件夹迁移后未看到步骤定义

Java Selenium/Cucumber在文件夹迁移后未看到步骤定义,java,selenium,junit,cucumber,Java,Selenium,Junit,Cucumber,用于此操作的依赖项: 黄瓜芯-1.2.4 cucumber.html-0.2.3 cucumber-java-1.2.4 黄瓜-junit-1.2.4 junit-4.11 小黄瓜-2.12.2 cucumber-jvm-deps-1.0.3 我最近清理了我的dependencies文件夹结构,并认为我可能放错了什么东西,但我的问题是一个实例化问题,没有意义,因为我似乎把我的鸭子排在了黄瓜边上。以下是堆栈跟踪: cucumber.runtime.CucumberException: Failed

用于此操作的依赖项:

黄瓜芯-1.2.4 cucumber.html-0.2.3 cucumber-java-1.2.4 黄瓜-junit-1.2.4 junit-4.11 小黄瓜-2.12.2 cucumber-jvm-deps-1.0.3

我最近清理了我的dependencies文件夹结构,并认为我可能放错了什么东西,但我的问题是一个实例化问题,没有意义,因为我似乎把我的鸭子排在了黄瓜边上。以下是堆栈跟踪:

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
包含以下步骤的功能文件:

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=newwebdriverwait(ieDriver,5)ieDriver为空,这导致NPE。一旦我从非空值创建了ieDriver对象,就会执行预期的行为。

您能告诉我,LoginandMeetingCreation.java:19行中是什么吗?从LoginandMeetingCreation构造函数到导入的最后一个代码段中看到的所有代码。这是整个.java文件,问题是,您使用null调用newWebDriver(ieDriver,2)。而且WebDriverWait不能是没有驱动程序的首字母缩写。对不起,我在这篇文章之前删除了大量代码,基本上是为了显示我正在处理的内容的“框架”,忘记删除那一行。编辑了该行。如果从表面上看所有内容,它应该会引发异常错误,但cucumber runner甚至不知道步骤定义甚至存在于LoginandMeetingCreation.java文件中
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();

    }
}