Python 脚本无法在 Azure 上调用 Chrome 驱动程序



当我在 azure 上检查我的自动化脚本时,它试图调用 chrome 驱动程序,它给了我以下错误。脚本是用python编写的。

[05/19/2017 11:36:19 > cbe7c6: INFO] step2
[05/19/2017 11:36:19 > cbe7c6: ERR ]   File "seleniumtest.py", line 21, in <module>
[05/19/2017 11:36:19 > cbe7c6: ERR ]     driver = webdriver.Chrome(executable_path="D:\home\site\wwwroot\env\chromeinstaller\Chrome\Application\chrome.exe")
[05/19/2017 11:36:19 > cbe7c6: ERR ]   File "D:homesitewwwrootenvLibsite-packagesseleniumwebdriverchromewebdriver.py", line 62, in __init__
[05/19/2017 11:36:19 > cbe7c6: ERR ]     self.service.start()
[05/19/2017 11:36:19 > cbe7c6: ERR ]   File "D:homesitewwwrootenvLibsite-packagesseleniumwebdrivercommonservice.py", line 64, in start
[05/19/2017 11:36:19 > cbe7c6: ERR ]     stdout=self.log_file, stderr=self.log_file)
[05/19/2017 11:36:19 > cbe7c6: ERR ]   File "D:Python27libsubprocess.py", line 710, in __init__
[05/19/2017 11:36:19 > cbe7c6: ERR ]     errread, errwrite)
[05/19/2017 11:36:19 > cbe7c6: ERR ]   File "D:Python27libsubprocess.py", line 958, in _execute_child
[05/19/2017 11:36:19 > cbe7c6: ERR ]     startupinfo)
[05/19/2017 11:36:19 > cbe7c6: ERR ] WindowsError: [Error 14001] The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail
[05/19/2017 11:36:19 > cbe7c6: SYS INFO] Status changed to Failed
[05/19/2017 11:36:19 > cbe7c6: SYS ERR ] Job failed due to exit code 1

根据你的错误信息,根据我的经验,我认为你正在使用 Azure 应用服务来尝试驱动通过 Web 驱动程序上传的 chrome,以加载一些动态 Web 内容以提取某些内容。

但是,根据 Azure Web App 沙盒的限制,您无法在 Azure WebApp 上使用任何将调用 GDI 系统的内容。关于Windows错误,您可以参考此处了解更多详情。

作为一种解决方法,我的建议是可以尝试在 Azure VM 上运行代码。或者根据我基于此线程标签的猜测,我认为您可能只想通过带有 chromedriver 的 webdriver 进行一些 web 单元测试,请参阅此处。

转到 Google Chrome 文件位置或桌面快捷方式图标 ->右键单击 ->属性 ->打开文件位置。

您将看到铬的两个应用:铬.exe和chrome_new.exe。运行chrome_new.exe,它将删除并替换以前的chrome.exe。

之后,您现在可以再次启动并使用谷歌浏览器。

最新更新