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