selenium - 如何自动化使用外部应用程序的网站?
问题描述
打开外部应用程序?
https://webiste.com 想要打开这个应用程序。
[x] 始终允许 website.com 在相关应用中打开此类链接
[取消] [打开外部应用程序]
我正在尝试自动化使用外部应用程序的流程。Chrome 正在请求打开应用程序的权限(见上文),但我无法找到一种方法来自动与该对话框进行交互。
有人建议我可以通过将命令行参数传递给 Chrome 来禁用该对话框。我得到了这个列表,但它很大,我没有找到任何看起来有用的东西。
如果有人曾经设法自动化使用外部应用程序的东西,请告诉我你是如何做到的。谢谢。
编辑:
这些是自动化框架用于启动 Chrome 的参数:
使用以下标志启动 Google Chrome:--enable-automation --disable-popup-blocking --disable-extensions --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --禁用同步 --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --no-default-browser-check --disable-hang-monitor --disable-prompt -on-repost --disable-client-side-phishing-detection --password-store=basic --use-mock-keychain --disable-component-extensions-with-background-pages --disable-breakpad --disable -dev-shm-usage --disable-ipc-flooding-protection --disable-renderer-backgrounding --force-fieldtrials=*BackgroundTracing/default/ --enable-features=NetworkService,NetworkServiceInProcess --disable-features=site-每个进程,TranslateUI,BlinkGenPropertyTrees --window-position=0,0 --window-size=1200,900
我可以轻松添加标志。不确定是否要删除标志。
解决方案
这并不理想,但它是一种解决方法:
remote({
logLevel: 'trace',
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--user-data-dir=./profile']
}
}
})
通过设置用户数据目录,您可以在第一次运行时手动授予始终允许权限,然后将其保存并记住以供将来运行。我尚未检查将其提交到您的存储库是否可行,但这可能使其在任何其他系统上工作而无需进行初始设置。
作为旁注,我发现 puppeteer 具有覆盖权限的能力,但没有提到打开外部应用程序。如果得到支持,我认为这将是理想的解决方案。
推荐阅读
- python - python中的[:,:-1]是什么?
- r - 如何在树状图中提取某个具有高度的节点下的标签?
- python - 如何使用 pywinauto 运行简单的 pytest-bdd 测试?
- python - 当我专门双击左键时,Pyqt5 崩溃而没有错误(双右键有效)
- php - 我不能在 yii2 中使用供应商包 - 找不到类
- .net - IBM MQ 2538 错误协商 SSL 连接
- json - VueJS 搜索过滤器错误:无法准备好未定义的“搜索”
- java - 在 Java 中计算出 Linux 纪元时间属于哪一天
- reactjs - React Apollo Query 使用 pollInterval 不断发出网络请求
- jquery - 超过 3000 个项目导出到 chrome 中的 excel 问题