简体   繁体   English

Python 3.5 Selenium Webdriver Chrome浏览器

[英]Python 3.5 Selenium Webdriver Chrome

I got selenium work with Firefox and IE but I can't get work with Chrome yet :S 我可以在Firefox和IE上使用硒,但现在还不能在Chrome上使用:S

this is my code (simple just to check): 这是我的代码(只需检查即可):

from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://www.google.com')

The problem is that Chrome open the window but after get stuck, doesn't neither go to the webpage and I receive this error: 问题是Chrome打开了窗口,但是在卡住后,既没有转到网页,也收到此错误:

Traceback (most recent call last): File "C:/Users/Carlo/Desktop/CEx/src/IE.py", line 21, in driver.get(' https://www.google.com ') File "C:\\Python35-32\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py", line 248, in get self.execute(Command.GET, {'url': url}) File "C:\\Python35-32\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py", line 234, in execute response = self.command_executor.execute(driver_command, params) File "C:\\Python35-32\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py", line 407, in execute return self._request(command_info[0], url, body=data) File "C:\\Python35-32\\lib\\site-packages\\selenium\\webdriver\\remote\\remote_connection.py", line 439, in _request resp = self._conn.getresponse() File "C:\\Python35-32\\lib\\http\\client.py", line 1197, in getresponse response.begin() File "C:\\Python35-32\\lib\\http\\client.py", line 297, in begin version, status, reason = self._read_status() File "C:\\Python35-32\\lib\\http\\client.py", line 258, in _read_status l 追溯(最近一次通话):文件“ C:/Users/Carlo/Desktop/CEx/src/IE.py”,第21行,位于driver.get(' https://www.google.com ')文件中C:\\ Python35-32 \\ lib \\ site-packages \\ selenium \\ webdriver \\ remote \\ webdriver.py“,第248行,位于get self.execute(Command.GET,{'url':url})文件” C:\\执行响应中的Python35-32 \\ lib \\ site-packages \\ selenium \\ webdriver \\ remote \\ webdriver.py“行234 = self.command_executor.execute(driver_command,params)文件” C:\\ Python35-32 \\ lib \\ site -packages \\ selenium \\ webdriver \\ remote \\ remote_connection.py“,行407,在执行返回self._request(command_info [0],url,body = data)文件” C:\\ Python35-32 \\ lib \\ site-packages \\ selenium \\ webdriver \\ remote \\ remote_connection.py”,第439行,在_request中resp = self._conn.getresponse()文件“ C:\\ Python35-32 \\ lib \\ http \\ client.py”,行1197,在getresponse响应中。 begin()文件“ C:\\ Python35-32 \\ lib \\ http \\ client.py”,第297行,开始版本,状态,原因= self._read_status()文件“ C:\\ Python35-32 \\ lib \\ http \\ client.py”,第258行,在_read_status l中 ine = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "C:\\Python35-32\\lib\\socket.py", line 575, in readinto return self._sock.recv_into(b) ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host ine = str(self.fp.readline(_MAXLINE + 1),“ iso-8859-1”)文件“ C:\\ Python35-32 \\ lib \\ socket.py”,第575行,在readin中返回self._sock.recv_into (b)ConnectionResetError:[WinError 10054]现有连接被远程主机强行关闭

The problem is that I don't have any other connection open :S and when it open the chrome window on the top of the page I receive this: 问题是我没有打开任何其他连接:S,当它打开页面顶部的Chrome窗口时,我收到以下消息:

You are using an unsupported command-line flag: --ignore-certificate-errors. 您正在使用不受支持的命令行标志:--ignore-certificate-errors。 Stability and security will suffer. 稳定性和安全性将受到损害。

I really believe that this is causing the not working of selenium but I'm not getting it right! 我真的相信这会导致硒无法正常工作,但是我做错了! some help pls?!?!?!?! 一些帮助请?!?!!?!?!

Try to use following code and let me know in case of any issues: 尝试使用以下代码,如有任何问题,请通知我:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("test-type")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('https://www.google.com')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM