在selenium Maven项目中java.lang.NullPointerException错误

时间:2017-08-28 10:12:48

标签: java maven selenium selenium-webdriver

目前,我将我的项目eclipse设置为智能IDE。在我的eclipse中一切都很好。但是在智能IDE中。我收到错误java.lang.NullPointerException。我没有得到任何想法如何解决

我目前的代码我遇到了IDE

ChromeDriver wd;


@BeforeMethod
public void setUp() throws Exception {
   wd = new ChromeDriver();
    wd.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

}
@Test(priority =31 ,retryAnalyzer = Retry.class)
public void AirBNB_add_show_One_Time() throws InterruptedException {
    wd.manage().window().maximize();
    wd.get("http://local.something.io/refine?amenity_keyword=internet&amenities=21&minimum_price=50&maximum_price=200&amount=50-200&order=2&changed_currency=USD&pax=4&date_end=2017-08-30&date_start=2017-08-28&view=grid&sqs=&location_id=&search=Paris%2C+France");
    wd.findElement(By.xpath(".//*[@class='airbnb-wide-block-search-btn js-airbnb-search-btn']")).click();

Thread.sleep(10000);
for (String windows : wd.getWindowHandles()) {

    wd.switchTo().window(windows);
    String CurrentURL = wd.getCurrentUrl();
    if (CurrentURL.startsWith("http://local.alojamiento.io")) {
        wd.navigate().refresh();
        Thread.sleep(7000);

        boolean imoverlayadd=wd.findElement(By.xpath("")).isDisplayed();
        boolean airbnb=wd.findElement(By.xpath(".//*[@class='airbnb-wide-block-search-btn js-airbnb-search-btn']")).isDisplayed();
        assertFalse(airbnb,"Airbnb Add will not show After clicking Add one times");
    }}  
}

@AfterMethod
public void tearDown() {

    driver.quit();
}

当我查看代码时,我收到了以下错误

java.lang.NullPointerException
at vrs.RentbyownerAutomationFinal.AnalyticsCode(RentbyownerAutomationFinal.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

0 个答案:

没有答案