0

Eclipse 控制台错误:

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 amazon.StartApplication.main(StartApplication.java:58)

Appium日志:

    {"strategy":"id","selector":"in.amazon.mShop.android.shopping:id/sign_in_button","context":"","multiple":false}}
    [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"in.amazon.mShop.android.shopping:id/sign_in_button","context":"","multiple":false}}
    [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
    [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
    [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'in.amazon.mShop.android.shopping:id/sign_in_button' using 'ID' with the contextId: '' multiple: false
    [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=in.amazon.mShop.android.shopping:id/sign_in_button]
    [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"2"}}
    [debug] [AndroidBootstrap] Received command result from bootstrap
    [debug] [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"2"}
    [info] [HTTP] <-- POST /wd/hub/session/fb4c547d-3a81-4b48-b6ff-cb14eb629138/element 200 28 ms - 87 

等待 60 秒:

waited 60 seconds for a command
[debug] [AndroidDriver] Shutting down Android driver

Appium 服务器在 1 分钟后关闭

4

2 回答 2

0

默认的 appium new 命令超时值为 60 秒,这就是 appium 服务器在 60 秒后关闭驱动程序的原因。您可以通过设置以下功能来更改默认超时:

capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 6000);

或者

capabilities.setCapability("newCommandTimeout", 6000);
于 2018-01-10T07:51:05.823 回答
0

首先,NullPointerException在 Java 中,只有当它引用的对象是null.

因此,您在这种情况下使用的变量可能是null并且您正在对其执行一些调用,例如:

element.click ();

在这里,元素可能是null

所以你需要优雅地处理这种情况。如果 element 是null,不要去点击它,而是记录错误并退出。

于 2018-01-10T12:42:04.177 回答