请找到用eclipse编写的代码: 点击该元素的代码就行了空指针异常,请帮我这个,我已经投入了这么多时间,如果有人解决它会有很大的帮助。
public class StartApplication {
private static AndroidDriver<WebElement> driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/apps/Hooq/");
File app = new File(appDir, "tv.hooq.android.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "eeefe839");
capabilities.setCapability("platformVersion", "6.0.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "tv.hooq.android");
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Thread.sleep(4000);
driver.findElementById("tv.hooq.android:id/accountLogin").click();
}
}
请从控制台中找到例外:
Exception in thread "main" java.lang.NullPointerException
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83)
at StartApplication.main(StartApplication.java:29)
答案 0 :(得分:0)
如果有一个应用程序的启动画面,那么只需要隐式等待,即driver.manage()。timeouts()。implicitlyWait(10,TimeUnit.SECONDS)
在findElementId之前。这只是因为启动画面而发生的
由于