解除权限对话框警报后,WebDriver 未检测到单击的底部元素
WebDriver not detecting the buttom element for click after dismssing the permission dialog alert
我在 Android 的 appium 上使用 WdAndroid 来 运行 自动化测试。我卡住的部分是第一次安装应用程序时,它会弹出权限对话框(位置权限)。我正在使用以下代码接受许可。
driver.elementById('com.android.packageinstaller:id/permission_allow_button').click()
对话框消失后,我想单击 activity 的按钮来执行所需的操作,使用下面的代码片段来实现。
const intervalObj = setInterval(() => {
driver.elementById('com.testpackage.testapp:id/testClickButton').click();
clearInterval(intervalObj);
}, 3000);
但上述操作不起作用,我在 appium 日志中收到以下错误
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding
'com.testpackage.testapp:id/testClickButton' using 'ID' with the
contextId: '' multiple: false [debug] [AndroidBootstrap] [BOOTSTRAP
LOG] [debug] Using: UiSelector[INSTANCE=0,
RESOURCE_ID=com.testpackage.testapp:id/testClickButton] [debug]
[AndroidBootstrap] Received command result from bootstrap [HTTP] <--
POST /wd/hub/session/88f58979-f7ff-4d52-b840-e930d4a04804/element 500
116 ms - 164 [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug]
Returning result: {"status":7,"value":"No element found"}
自动化流程是接受权限并等待 3 秒以执行单击按钮。但这并没有发生。
但是,如果我删除权限警报对话框,然后使用上面的代码片段来点击按钮,它就可以正常工作。仅当关闭对话框且自动化未找到按钮时才会出现问题。
I am writing the automation source code in Node.JS.
您可以尝试在接受对话框后立即将您的应用程序发送到后台吗?有了这个,您将重新关注您的应用
driver.elementById('com.android.packageinstaller:id/permission_allow_button').click()
driver.runAppInBackground(0)
之后您可以再次搜索元素。
您的驱动程序还可以自动接受您的权限
capabilities.setCapability("autoGrantPermissions", "true");
我想建议的另一个功能是 'noReset' 这样就不会在您每次启动应用程序时都询问这些权限,只是第一次:
capabilities.setCapability("noReset", "true");
我在 Android 的 appium 上使用 WdAndroid 来 运行 自动化测试。我卡住的部分是第一次安装应用程序时,它会弹出权限对话框(位置权限)。我正在使用以下代码接受许可。
driver.elementById('com.android.packageinstaller:id/permission_allow_button').click()
对话框消失后,我想单击 activity 的按钮来执行所需的操作,使用下面的代码片段来实现。
const intervalObj = setInterval(() => {
driver.elementById('com.testpackage.testapp:id/testClickButton').click();
clearInterval(intervalObj);
}, 3000);
但上述操作不起作用,我在 appium 日志中收到以下错误
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.testpackage.testapp:id/testClickButton' using 'ID' with the contextId: '' multiple: false [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.testpackage.testapp:id/testClickButton] [debug] [AndroidBootstrap] Received command result from bootstrap [HTTP] <-- POST /wd/hub/session/88f58979-f7ff-4d52-b840-e930d4a04804/element 500 116 ms - 164 [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
自动化流程是接受权限并等待 3 秒以执行单击按钮。但这并没有发生。
但是,如果我删除权限警报对话框,然后使用上面的代码片段来点击按钮,它就可以正常工作。仅当关闭对话框且自动化未找到按钮时才会出现问题。
I am writing the automation source code in Node.JS.
您可以尝试在接受对话框后立即将您的应用程序发送到后台吗?有了这个,您将重新关注您的应用
driver.elementById('com.android.packageinstaller:id/permission_allow_button').click()
driver.runAppInBackground(0)
之后您可以再次搜索元素。
您的驱动程序还可以自动接受您的权限
capabilities.setCapability("autoGrantPermissions", "true");
我想建议的另一个功能是 'noReset' 这样就不会在您每次启动应用程序时都询问这些权限,只是第一次:
capabilities.setCapability("noReset", "true");