【问题标题】:Python 3.5 Selenium Webdriver ChromePython 3.5 Selenium Webdriver Chrome
【发布时间】:2016-11-16 15:09:59
【问题描述】:

我在 Firefox 和 IE 上获得了 selenium 工作,但我还不能在 Chrome 上工作:S

这是我的代码(只是为了检查):

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

问题是Chrome打开窗口但卡住后,既没有进入网页,我收到这个错误:

Traceback(最近一次调用最后一次):文件 “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 行,在获取 self.execute(Command.GET, {'url': url}) 文件 "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", 第 234 行,执行中 response = self.command_executor.execute(driver_command, params) 文件 “C:\Python35-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py”,第 407 行,在执行中 return 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 response.begin() 文件“C:\Python35-32\lib\http\client.py”,第 297 行,开始 版本、状态、原因 = self._read_status() 文件“C:\Python35-32\lib\http\client.py”,第 258 行,在 _read_status line = 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] 现有连接被远程主机强行关闭

问题是我没有打开任何其他连接:S,当它打开页面顶部的 chrome 窗口时,我收到了这个:

您正在使用不受支持的命令行标志: --忽略证书错误。稳定性和安全性将受到影响。

我真的相信这会导致硒不起作用,但我没有做对!请帮忙?!?!?!?!

【问题讨论】:

    标签: python windows selenium selenium-chromedriver


    【解决方案1】:

    尝试使用以下代码,如有任何问题,请告诉我:

    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')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-27
      • 2017-07-17
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      • 2018-02-18
      • 2019-11-15
      相关资源
      最近更新 更多