[英]Unable to find an element in Browser of the Android emulator using Appium and C#
[英]How to handle Android permission Dialogues using Appium C#
我不知道你在哪里獲得這個permission_allow_button
ID,我不認為定位器是正確的。
以下是我在Android Device Monitor應用程序中的樣子
因此,如果您仍想使用通過ID查找元素的策略 - 您應該使用com.android.packageinstaller:id/permission_allow_button
ID。
另一個選擇是XPath選擇器,如:
//Button[@text()='ALLOW]
//Button[@resource-id='com.android.packageinstaller:id/permission_allow_button']
您只能通過Xpath定位器來完成。 按ID查找不適用於權限對話框處理。 要找到“允許”按鈕,您可以使用
driver.find_element_by_xpath("//*[@class='android.widget.Button'][2]") //it denotes "Allow" button
而對於“DENY”按鈕,
driver.find_element_by_xpath("//*[@class='android.widget.Button'][1]") //it denotes "Deny" button
在單擊按鈕之前,您應該等到元素找到
WebDriverWait wait = new WebDriverWait(driver, timeOut);
wait.until(ExpectedConditions.presenceOfElementLocated(element));
希望這會幫助你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.