Python 3.5 Selenium Webdriver Chrome(Python 3.5 Selenium Webdriver Chrome)
我使用Firefox和IE获得了selenium,但我还是无法使用Chrome:S
这是我的代码(简单只是为了检查):
from selenium import webdriver driver = webdriver.Chrome() driver.get('https://www.google.com')
问题是Chrome打开窗口但是在卡住之后,既没有进入网页也没有收到此错误:
回溯(最近一次调用最后一次):文件“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”)文件“C:\ Python35-32 \ lib \ socket.py”,第575行,在readinto中返回self._sock.recv_into (b)ConnectionResetError:[WinError 10054]远程主机强行关闭现有连接
问题是我没有打开任何其他连接:S,当它打开页面顶部的chrome窗口时,我会收到:
您使用的是不受支持的命令行标志: - ignore-certificate-errors。 稳定性和安全性将受到影响
我真的相信这导致硒不起作用,但我没有做对! 有些帮助吗?!?!?!?!
I got selenium work with Firefox and IE but I can't get work with Chrome yet :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:
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 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] An existing connection was forcibly closed by the remote host
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:
You are using an unsupported command-line flag: --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?!?!?!?!
最满意答案
尝试使用以下代码,如有任何问题,请告知我们:
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')
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')
相关问答
更多-
Selenium Webdriver无法创建chrome webdriver实例(Selenium Webdriver Unable to create chrome webdriver instance)[2022-06-05]
当我将包含“backports”gem的gem作为其依赖项的一部分包含在我的Gemfile中时,我看到了这一点。 backports gem重写了一些Ruby 1.8内部,它覆盖了部分UDPSocket核心类。 尝试摆脱backports宝石并给它一个机会。 I saw this when I had included a gem which included the "backports" gem as part of its dependencies into my Gemfile. The backp ... -
是的,在这种特殊情况下应该使用find_element_by_id , find_element_by_xpath或find_element_by_css_selector 。 我怀疑elem = driver.find_element_by_name("session[username_or_email]")因为方括号而无效。 对于任何需要使用Selenium处理方括号的人来说,使用css选择器或xpath应该更容易,如下例所示(方括号在本例中的类名中):
相关文章
更多- 基于struts2.18+spring3.0+hibernate3.5+annotation的用户权限
- Solr 3.5 入门配置应用
- Solr 3.5 入门配置应用
- Solr 3.5 入门配置应用
- solr 3.5 配置及应用(二)
- solr 3.5 配置及应用(三)
- solr 3.5 配置及应用(一)
- chrome如何强制刷新页面?
- 《WordPress 3.5 基础教程》(WordPress 3.5 Essential Training)[光盘镜像]
- Python内建函数(F)
最新问答
更多- 在javascript中创建类以创建对象并在Java中创建类和对象之间的区别(Difference between creating a class in javascript to create an object and creating an class and object in Java)
- Facebook API:将身份验证详细信息从Javascript SDK发送到PHP SDK(Facebook API: Send authentication detail from Javascript SDK to PHP SDK)
- 如何停止队列动画jquery?(How can I stop queue animation jquery?)
- 使用C#的井字游戏中的人工智能(Artificial Intelligence in Tic-Tac-Toe using C#)
- 多少流量可以共享虚拟主机(对于Python Django站点)支持?(How Much Traffic Can Shared Web Hosting (for a Python Django site) support?)
- 带有CIFilters的CAShapeLayer(CAShapeLayer with CIFilters)
- 如何在Angular 2中读取JSON #text(How to read in Angular 2 the JSON #text)
- 如何在xml中读取自闭标签的属性?(How to read self closing tag's attribute in xml?)
- 无法使用http put将图像上传到亚马逊S3(Cannot upload image to amazon s3 using http put)
- 文件结束无限循环(end of file infinite while-loop)
- 在cpp的模板(template in cpp)
- 在构建库时,clang和clang ++有什么区别?(What's the difference between clang and clang++ when building a library?)
- ng类中的表达式(expression inside ng-class)
- 在PHP中获取随机布尔值true / false(Get random boolean true/false in PHP)
- 管道的高效分块用于严格的字节串(Efficient chunking of conduit for strict bytestring)
- Python ternary_operator(如果其他标志做了其他操作,则执行其他操作)(Python ternary_operator (do-somthing if flag else do-another))
- Sencha Touch面具发布(Sencha Touch mask ondisclosure)
- 验证脚本上的通知[重复](Notices on validation script [duplicate])
- 朋友功能(friend function)
- 基于角坐标平移和变换平面几何(Translate and transform plane geometry based on corner coordinates)
- Rails:'如果在本地运行'条件javascript标记包括(Rails: 'if running locally' conditional javascript tag include)
- 解压文件(Unzipping files)
- 使用ui-router以角度加载变量状态(loading in variable states with ui-router in angular)
- 创建Azure云服务需要多长时间?(how long does it take to create an Azure Cloud Service? How to view log information?)
- 指向整数的指针数组(Array of pointers to integers)
- Laravel服务提供商没有看到我的包的主要类(Laravel service provider does not see the main class of my package)
- 这个关于VSS / RSS / PSS / USS的解释是否准确?(Is this explanation about VSS/RSS/PSS/USS accurate?)
- 在Django-Admin中通过row-id排序显示项目(Ordering the display items by row-id in Django-Admin)
- 如何使用cythonize启用`--embed`?(How to enable `--embed` with cythonize?)
- 用于将文本多行设置的Excel脚本(Excel script for ereasing text multiple rows)