我正在尝试进行黄瓜测试,以打开浏览器,转到网页,然后单击一下。但是我一直收到java.lang.NullPointerException
。我对这可能是什么以及如何对其进行分类的想法不多了。有人可以帮我吗?
public class LoginSteps {
WebDriver driver;
@Before()
public void setup(){
System.setProperty("webdriver.chrome.driver", "C:\\Workstuff\\webdrivers\\chromedriver.exe");
this.driver = new ChromeDriver();
this.driver.manage().window().maximize();
this.driver.manage().timeouts().pageLoadTimeout(120, TimeUnit.SECONDS);
}
@Given("^User goes to webdriveruniversity$")
public void user_goes_to_webdriveruniversity() throws Throwable {
driver.navigate().to("http://webdriveruniversity.com/");
}
```java.lang.NullPointerException
at Cucumber.features.steps.LoginSteps.user_goes_to_webdriveruniversity(LoginSteps.java:29)
at ✽.Given User goes to webdriveruniversity(C:/Users/homez/Cucumber/src/test/java/Cucumber/features/ContactUs.feature:5)
Skipped step
答案 0 :(得分:0)
偶然发现我的问题,而不是导入
import cucumber.api.java.Before;
我做了
import org.junit.Before;