首先我們先看看這個gif,圖中需要,要抓取的字符串--->請輸入轉讓份數
1、要導入java-client-5.0.0-SNAPSHOT.jar
包的地址:鏈接:http://pan.baidu.com/s/1hsfydLU 密碼:ktbn
2、// 調用uiautomator2,獲取toast,要先調用java-client-5.0.0-SNAPSHOT.jar
(先前的java-client 包要先移出library)然后
在初始化時加上下面這句代碼調用
//caps.setCapability(MobileCapabilityType.AUTOMATION_NAME,AutomationName.ANDROID_UIAUTOMATOR2);
3、尋找的代碼
String toast="請輸入轉讓份數";
//toast 尋找測試
try {
final WebDriverWait wait = new WebDriverWait(driver,2);
Assert.assertNotNull(wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[contains(@text,'"+ toast + "')]"))));
System.out.println("找到了toast");
} catch (Exception e) {
throw new AssertionError("找不到"+toast);
}
注意:要移出其它的java-client的包,如