【发布时间】:2018-09-10 15:13:44
【问题描述】:
我编写了一个应用程序,其中包含一个按钮,它将显示一条 toast 消息。
public void onClickShowToast(View view) {
Toast.makeText(getBaseContext(), "Change port successfully", Toast.LENGTH_LONG).show();
}
然后,我用 appium 写了一个测试用例尝试验证它。
//APPIUM Version: 1.6.3;
//JAVA: 1.8;
//JAVA Client: 5.0.0;
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
driver.findElementByXPath("//*[contains(@text,'Button')]").click();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[contains(@text, 'port')]")))
但是,结果是失败:
org.openqa.selenium.TimeoutException:预期条件失败: 等待存在的元素位于:By.xpath: //*包含(@text, 'port')
【问题讨论】: