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 ...
随机推荐
- C++多线程基础学习笔记(六)
condition_variable.wait.notifiy_one.notify_all的使用方式 condition_variable:条件变量 wait:等待被唤醒 notify_one:随机 ...
- Power Tower(广义欧拉降幂)
题意:https://codeforc.es/contest/906/problem/D 计算区间的: ai ^ ai+1 ^ ai+2.......ar . 思路: 广义欧拉降幂: 注意是自下而上递 ...
- spark教程(14)-共享变量
spark 使用的架构是无共享的,数据分布在不同节点,每个节点有独立的 CPU.内存,不存在全局的内存使得变量能够共享,驱动程序和任务之间通过消息共享数据 举例来说,如果一个 RDD 操作使用了驱动程 ...
- mysql事务、redo日志、undo日志、checkpoint详解
转载: https://zhuanlan.zhihu.com/p/34650908 事务: 说起mysql innodb存储引擎的事务,首先想到就是ACID(不知道的请google),数据库是如何做到 ...
- python网络爬虫(6)爬取数据静态
爬取静态数据并存储json import requests import chardet from bs4 import BeautifulSoup import json user_agent='M ...
- Collection接口的子接口——Set接口
https://docs.oracle.com/javase/8/docs/api/java/util/Set.html public interface Set<E> extends ...
- Scala新版本学习(1):
1.进官网:https://www.scala-lang.org/ 上面就是进入Scala社区后的一个画面,官方对Scala的简单介绍是:Scala将面向对象和函数式编程集合在一个简洁的高级语言中,S ...
- chrome 浏览器安装 postman
chrome 浏览器安装 postman(插件下载见文章末尾) 1.安装方法 将下载的crx插件拖拽到chrome浏览器即可安装成功. 2.特殊情况 问题: chrome73版本后拖拽安装chrome ...
- Linux操作系统的常用命令(一)
一.写随笔的原因:上次提到centos7.3安装mysql5.7的一些步骤,恰巧最近面试有碰到一些问LInux操作的常用操作的问题,想通过这篇文章MARK一下,不一定能够全,只是用的比较多的吧(lin ...
- centos7 Keepalived + Haproxy + MySQL pxc5.6
拓扑图 应用通过 VIP 连接到 Haproxy,Haproxy 通过http代理分发请求到后端 3 台 MySQL pxc. Keepalived 可以有效防止 Haproxy 单点故障. MySQ ...