Appium-使用Chrome将文件上传到网络-ERR_ACCESS_DENIED
我正在尝试使用 Appium 通过 Chrome将文件上传到https://the-internet.herokuapp.com/upload。但它总是导致ERR_ACCESS_DENIED错误。
该文件位于Download我设备的文件夹中。
参考下图:
我也用不同的组合尝试了以下功能,但没有帮助:noReset, autoGrantPermissions, fastReset.
我的脚本:
from appium import webdriver
import time
def execute_script():
driver = webdriver.Remote(
command_executor='http://0.0.0.0:4723/wd/hub',
desired_capabilities={
"platform": "android",
"platformName": "android",
"platformVersion": "10",
"deviceName": "<xxxx>",
"udid": "<xxxx>",
"browserName": "chrome",
"automationName": "UIAutomator2",
"chromeOptions": {
"w3c": False
},
# "autoGrantPermissions": True,
# "noReset": True,
# "fastReset": True,
# "fullReset": False
}
)
driver.get('https://the-internet.herokuapp.com/upload')
up = driver.find_element_by_id("file-upload")
up.send_keys("/sdcard/Download/file.pdf")
driver.find_element_by_id("file-submit").click()
driver.quit()
driver = execute_script()
脚本执行良好,直到这send_keys一步。但是一旦file-submit执行点击,就会导致上述错误。我也在https://fileconvoy.com/上尝试过,但结果是同样的错误。
版本详情:
- Appium 版本:(
1.17.0尝试版本从1.10.x到1.20.x) - 设备:三星 Galaxy S9,Android 10
- Chromedriver:90.0.4430.24(也试过 Chrome 81,同样的错误)。
我尝试过的一切:
- 在启动 appium 之前通过以下命令明确授予权限(如果权限被重置,也在脚本的中间),但没有运气。
adb -P 5037 shell 'pm grant com.android.chrome android.permission.READ_EXTERNAL_STORAGE android.permission.WRITE_EXTERNAL_STORAGE'
browserName: "Chrome"我还尝试指定appPackage and appActivity开始 chrome ,而不是使用。但没有运气。
我从根本上缺少什么吗?这在桌面浏览器上运行良好(使用 selenium)。但是我一直无法在我的移动设备上运行它。
如果还有什么我应该分享的,请告诉我。
在 Appium 上也创建了一个问题:https : //github.com/appium/appium/issues/15293
THE END
二维码