Chrome受到自动测试软件“不安全"的控制,数据:,Python [英] Chrome is being controlled by automated test software "not secure" data:, Python

查看:62
本文介绍了Chrome受到自动测试软件“不安全"的控制,数据:,Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用python中的硒库打开google chrome并自动访问google.com,这就是我目前的脚本

I'm using the selenium library in python to open google chrome and visit google.com automatically, this is how my script looks like at the moment

import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options


chromedriver = "/usr/bin/chromedriver"

os.environ["webdriver.chrome.driver"] = chromedriver
chrome_options = webdriver.ChromeOptions()
chrome_options.accept_untrusted_certs = True
chrome_options.assume_untrusted_cert_issuer = True
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--allow-http-screen-capture")
chrome_options.add_argument("--disable-impl-side-painting")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--disable-seccomp-filter-sandbox")
chrome_options.add_options("--enable-automation")
chrome_options.add_options("--disable-infobar")
driver = webdriver.Chrome(chromedriver, chrome_options=chrome_options)

driver.get("http://google.com/")

我的浏览器选项卡从不显示google.com,它只是挂在这里

My browser tab never displays google.com and it just hangs there This is the picture of how my browser looks like when I run the script

我的chromedriver版本是:ChromeDriver 2.39我的Google Chrome版本是:Google Chrome 67.0

My version of chromedriver is: ChromeDriver 2.39 My Google Chrome version is : Google Chrome 67.0

执行Ctrl + c后,我得到此输出

After doing Ctrl+c, i get this output

Traceback (most recent call last):
File "auto-run.py", line 16, in <module>
driver = webdriver.Chrome(chrome_path, chrome_options=chrome_options)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 245, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 472, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 496, in _request
resp = self._conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
KeyboardInterrupt

对于--enable-automation不起作用的任何帮助,将不胜感激!

Any help as to why --enable-automation does not work would be greatly appreciated!

推荐答案

我以这种方式修改了脚本,并能够成功执行

I modified your script in this way and was able to execute it successfully

import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_path  = '/Users/zac/Desktop/chromedriver_mac64/chromedriver'
#this would be the path to the chromedriver exe on your system

chrome_options = webdriver.ChromeOptions()
chrome_options.accept_untrusted_certs = True
chrome_options.assume_untrusted_cert_issuer = True
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--allow-http-screen-capture")
chrome_options.add_argument("--disable-impl-side-painting")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--disable-seccomp-filter-sandbox")
driver = webdriver.Chrome(chrome_path, chrome_options=chrome_options)

driver.get("http://google.com/")

此外,您需要对-enable-automation 标志

这篇关于Chrome受到自动测试软件“不安全"的控制,数据:,Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆