一般页面上有 Start 按钮,没有 Start 之前其他的元素都不可点:
但是如果 Start 之后就没有 Start,页面元素都可点:

现在的问题是我判断 Start 按钮是否存在时,总是会直接判断页面元素存在,不存在就直接报错,源码如下:

public void checkSPStatus(){
    if(driver.findElementById("com.ef.efekta.englishtown:id/planButton")==null){
        WebElement lessonOne = driver.findElementByXPath("//android.view.View[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.widget.RelativeLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.ImageView[1]");
        lessonOne.click();
    }
}

报错信息:

info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"88e61052-a8ec-48cd-bf98-bdc1567d4362"}
info: <-- POST /wd/hub/session/88e61052-a8ec-48cd-bf98-bdc1567d4362/element/3/click 200 285.858 ms - 76 {"status":0,"value":true,"sessionId":"88e61052-a8ec-48cd-bf98-bdc1567d4362"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: --> POST /wd/hub/session/88e61052-a8ec-48cd-bf98-bdc1567d4362/element {"using":"id","value":"com.ef.efekta.englishtown:id/planButton"}
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.ef.efekta.englishtown:id/planButton","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.ef.efekta.englishtown:id/planButton","context":"","multiple":false}}


↙↙↙阅读原文可查看相关链接,并与作者交流