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;
}
}
}