我正在进行 selenium 测试,我需要从 chrome 应用商店获取 chrome 扩展以在测试中使用。目前,更新到较新版本的扩展是一个手动过程。
Current Flow:
1. Manual download extension through a chrome extension downloader.
2. Store the .crx file in a location visible to the selenium test.
3. Execute test with that extension.
我希望谷歌有一个 API 可以用来下载扩展程序,但我一直找不到任何与此效果相关的内容。有谁遇到过这样的情况并能够解决吗?
最佳答案
基本上,您只需捕获重定向 URL,然后发出请求即可。
在Python中:
pluginId = 插件页面 url 末尾的 id。 here 上的选项 2解释得很好
blah=requests.get(url,params{'prodversion':'57.0','x':"id=pluginId",'response':'redirect'},verify=False,stream=True)
blahFile = requests.get(blah.url)
extension = open("yourExtension.crx", 'wb')
extension.write(blahFile.content)
extension.close()
关于python - 下载用于 selenium 测试的 chrome 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42955615/