python脚本中selenium启动浏览器报错os.path.basename(self.path), self.start_error_message) selenium.common.excep
在python脚本中,使用selenium启动浏览器报错,原因是未安装浏览器驱动,报错内容如下:
# -*- coding:utf-8 -*-
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.baidu.com")
报错提示如下所示:
Traceback (most recent call last):
File "D:\Program Files\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "D:\Program Files\Python36\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "D:\Program Files\Python36\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Program Files/Python36/baidu.py", line 4, in <module>
driver = webdriver.Firefox()
File "D:\Program Files\Python36\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "D:\Program Files\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
解决方案:安装Chrome浏览器驱动
1.下载 chromedriver_win32.zip,根据浏览器版本下载对应的压缩包;
下载地址:https://sites.google.com/a/chromium.org/chromedriver/downloads
2.解压后将chromedriver.exe文件放到系统环境变量Path路径下,例如:已将D:\Program Files\Python36\ 添加到系统环境变量Path路径下,将chromedriver.exe文件放到D:\Program Files\Python36\ 目录下即可;
3.将Chrome替换掉原脚本中的Firefox,保存文件并运行。
# -*- coding:utf-8 -*-
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
driver.find_element_by_id("kw").send_keys("Selenium2")
driver.find_element_by_id("su").click
driver.quit()
原文:https://blog.csdn.net/weixin_44612439/article/details/87983282
python脚本中selenium启动浏览器报错os.path.basename(self.path), self.start_error_message) selenium.common.excep的更多相关文章
- Shell脚本中"command not found"报错处理
字符串的定义与赋值 # 定义STR1变量,值为abc STR1 = "abc"(错误写法) STR1="abc"(正确写法) 在编写java代码时会考虑到格式化 ...
- python+selenium打开浏览器报错问题
报关键字,升级selenium版本 若打开IE浏览器,停在IE界面,无法跳转对应的地址,设置一下IE的页面缩放,设置为100%
- selenium 打开浏览器报错java.lang.NoSuchMethodError: org.openqa.selenium.chrome.ChromeOptions.addArguments([Ljava/lang/String;)
java.lang.NoSuchMethodError: org.openqa.selenium.chrome.ChromeOptions.addArguments([Ljava/lang/Strin ...
- 命令行可以执行python脚本,jenkins里执行报错:cannot find Chrome binary
“selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary”这个 ...
- IDEA中debug启动tomcat报错。Error running t8:Unable to open debugger port(127.0.0.1:49225):java.net.BindException"Address alread in use:JVM_Bind"
解决办法: 1,如下图打开项目配置的tomcat的“Edit Configurations...” 2,打开“Startup/Connection”--------"Debug"- ...
- 在datagrid中,IE浏览器报错:SCRIPT5007: 无法获取属性“rowspan”的值: 对象为 null 或未定义
项目总采用datagird时,产生界面如下图原本标题上有功能按钮,此时消失 错误:SCRIPT5007: 无法获取属性"rowspan"的值: 对象为 null 或未定义, 造 ...
- springcloud中config启动时候报错Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'config.info' in value "${config.info}"
-noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jm ...
- $Django 多表操作(增删改查,基于双下划线,对象的查询) 在Python脚本中调用Django环境
在Python脚本中调用Django环境. import osif __name__ == '__main__': os.environ.setdefault("DJANGO_SETTING ...
- 解决selenium 启动ie浏览器报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones
启动ie代码: System.setProperty("webdriver.ie.driver", "bin/IEDriverServer.exe"); Web ...
随机推荐
- FFmpeg4.0笔记:封装ffmpeg的解码功能类CDecode
Github https://github.com/gongluck/FFmpeg4.0-study/tree/master/Cff CDecode.h /********************** ...
- Fiddler--模拟弱网
1.首先要勾选Rules--Performance--Simulate Modem Speeds 2.点击Customer Rules 3.然后找到 修改这个值就好. 备注:修改完保存后,要重新勾选第 ...
- java native本地方法详解(转)
文章链接出处: 详解native方法的使用 自己实现一个Native方法的调用 JNI 开始本篇的内容之前,首先要讲一下JNI.Java很好,使用的人很多.应用极 广,但是Java不是完美的.Java ...
- CentOs 7.6 开启防火墙后 无法显示远程文件夹
转:https://blog.csdn.net/ygwlove0110/article/details/88232065 遇到了个坑.服务器开启了防火墙后,ftp客户端连接就无法显示目录.关掉防火墙就 ...
- Ubuntu分区挂载
创建主分区: 25G 主分区 空间起始位置 Ext4日志文件系统 / (ps:安装主要放这了,原因不明) 创建swap分区: 8192MB 逻辑分区 空间起 ...
- MongoDB v4.0 命令
MongoDB v4.0 命令 官方文档 > 点这里 < 操作系统库 #操作管理员库 use admin #鉴权 db.auth("root","admin& ...
- linux命令详解——yum
1.如果不知道确切名字可以:rpm -qa|grep pkgname 2.查看软件安装的文件:rpm -qpl pkgname 3.如果不知道提供某个软件的包是叫什么,可以使用类似下面的写法: yum ...
- Get To Know Linux: The /etc/init.d Directory
If you use Linux you most likely have heard of the init.d directory. But what exactly does this dire ...
- gitlab和jenkins的安装及使用
gitlab 准备: 最少4G内存 先安装docker软件包然后使用docker search gitlab 查找镜像然后使用docker pull 镜像名:标签名 下载镜像启动容器: docker ...
- linux进程调度的算法
linux进程的调度算法 这节我们来学习一下linux进程的优先级 linux进程的优先级 进程提供了两种优先级,一种是普通的进程优先级,第二个是实时优先级,前者使用SCHEED_NORMAL调度策略 ...