public void permission() {
for (int i=0; i <= 10; i++) {
if (getPageSource().contains("容许") || getPageSource().contains("禁止")
|| getPageSource().contains("受权")) {// 出现权限提示
try {
findElement(By.xpath("//android.widget.Button[contains(@text,'容许')]")).click();// 点击容许
} catch (NoSuchElementException e1) {
findElement(By.xpath("//android.widget.Button[contains(@text,'受权')]")).click();// 点击受权
}
} else {
break;
}
}
}
android