我是编程的新手,Python大约2个月前开始使用Python文本,正在浏览Sweigart的自动化无聊的东西.我正在使用IDLE并且已经安装了selenium模块和Firefox浏览器.每当我尝试运行webdriver函数时,我都会得到:
from selenium import webdriver
browser = webdriver.Firefox()
Run Code Online (Sandbox Code Playgroud)
例外: -
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00000249C0DA1080>>
Traceback (most recent call last):
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
self.stop()
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop
if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00000249C0E08128>>
Traceback (most recent call last):
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
self.stop()
File …Run Code Online (Sandbox Code Playgroud) 我在使用Selenium时遇到了问题.对于我的项目,我必须使用Chrome.但是,在使用Selenium启动它后,我无法连接到该浏览器.
出于某种原因,Selenium无法单独找到Chrome.当我尝试在不包含路径的情况下启动Chrome时会发生这种情况:
Traceback (most recent call last):
File "./obp_pb_get_csv.py", line 73, in <module>
browser = webdriver.Chrome() # Get local session of chrome
File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 46, in __init__
self.service.start()
File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/service.py", line 58, in start
and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path. Please download from http://code.google.com/p/selenium/downloads/list and read up at http://code.google.com/p/selenium/wiki/ChromeDriver'
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,我在启动Chrome的代码中包含了Chromium路径.但是,解释器无法找到要连接的套接字:
Traceback (most recent call last):
File "./obp_pb_get_csv.py", line 73, in <module>
browser = webdriver.Chrome('/usr/bin/chromium') # Get local session of …Run Code Online (Sandbox Code Playgroud) 我目前是机器人框架的新手。我目前正在使用最新的 chrome 和 chromedriver 窗口版本,它是 80,但是当我尝试运行测试时,它给出消息“SessionNotCreatedException:消息:未创建会话:此版本的 ChromeDriver 仅支持 Chrome pycharm 中的版本 81”,但目前仅提供 81 的测试版。我试过卸载所有东西并重新安装它,但没有任何效果任何人都可以帮助我解决这个问题。谢谢!
selenium google-chrome robotframework selenium-chromedriver selenium-webdriver
引用错误消息:'chromedriver'可执行文件需要在PATH中
我试图在pycharm中使用selenium编写脚本代码.但后来我得到了上述错误.我已将我的selenium链接到pycharm,如下所示:https://gyazo.com/b5622e3165bbfd93cfa205178df79b6f - (新鲜和最新)
我是selenium的新手,在"selenium"文件夹中不是chromedriver.如果它不在哪里可以找到并将其添加到路径中?
顺便说一句,我尝试在cmd中键入"chromedriver",它不被认为是内部或外部命令.
错误如下所示:
Traceback (most recent call last):
File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
PermissionError: [WinError 5] Permission denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/sebastian/PycharmProjects/web/bot.py", line 10, in <module>
browser = webdriver.Chrome("C:/Users/sebastian/desktop/selenium-3.0.1")
File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
self.service.start()
File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
os.path.basename(self.path), self.start_error_message) …Run Code Online (Sandbox Code Playgroud) 我在 Windows 上安装了 Chrome 115.0.5790.99,并且使用 Selenium 4.10.0。在我的 Python 代码中,我调用service = Service(ChromeDriverManager().install())并返回错误:
ValueError: url [sic] https://chromedriver.storage.googleapis.com/LATEST_RELEASE_115.0.5790没有这样的驱动程序。
我使用 ChromeDriverManager().install() 来确保使用最新稳定版本的 webdriver。如何解决问题?
我的简单代码:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import time
# Install Webdriver
service = Service(ChromeDriverManager().install())
# Create Driver Instance
driver = webdriver.Chrome(service=service)
# Get Web Page
driver.get('https://www.crawler-test.com')
time.sleep(5)
driver.quit()
Run Code Online (Sandbox Code Playgroud)
错误输出:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import time
# Install Webdriver
service = Service(ChromeDriverManager().install())
# Create …Run Code Online (Sandbox Code Playgroud) 我开始自动化无聊的东西书,我正在尝试通过python打开一个chrome web浏览器.我已经安装了硒和
我试过运行这个文件:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
browser = webdriver.Chrome()
browser.get('https://automatetheboringstuff.com')
Run Code Online (Sandbox Code Playgroud)
但正因为如此,我得到这个错误:
Traceback (most recent call last): File "C:\Program Files
(x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py",
line 74, in start
stdout=self.log_file, stderr=self.log_file) File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session) File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, in _execute_child
startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)
在处理上述异常期间,发生了另一个异常:
Traceback (most recent call last): File "C:/Program Files
(x86)/Python36-32/test.py", line 5, in <module>
browser = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用chromedriver执行一些测试,并尝试使用以下方法启动chromedriver.
driver = webdriver.Chrome('/usr/local/bin/chromedriver')
Run Code Online (Sandbox Code Playgroud)
和
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver')
Run Code Online (Sandbox Code Playgroud)
和
import os
from selenium import webdriver
chromedriver = "/usr/local/bin/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get("http://stackoverflow.com")
Run Code Online (Sandbox Code Playgroud)
但这些似乎都没有帮助,错误是: selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.
我已多次检查并且chromedriver位于现场/usr/local/bin.
我的脚本仍然无效.任何身体都可以帮助.
我的google-chrome位置是:/ usr/bin/google-chrome
尝试在python脚本中使用Selenium和Chrome.
我收到以下错误:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Run Code Online (Sandbox Code Playgroud)
我知道chromedriver可执行文件的位置.如何将其添加到PATH?
谢谢
我是Selenium的新人,我现在可以用selenium和Chromedriver做基本的自动测试,代码运行正常,但问题是Chrome浏览器总是在后端自动更新,Chrome更新后代码总是无法运行. 我知道我需要下载新的 chromedriver 来解决这个问题,但我想知道是否有任何方法可以在不禁用 chromebrowser 更新的情况下解决这个问题?tks。
我使用的是 Windows 10 / Chrome 版本 67 / Python 3.6.4 / Selenium 3.12.0
python selenium google-chrome selenium-chromedriver selenium-webdriver
我有一个错误:
E selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 102
E Current browser version is 109.0.5414.120 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Run Code Online (Sandbox Code Playgroud)
我已经使用代码来获取最新版本的 webdriver-
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
options = webdriver.ChromeOptions()
options.add_argument("--allow-running-insecure-content")
options.add_argument("--ignore-certificate-errors")
options.set_capability("acceptInsecureCerts", True)
preferences = {"profile.default_content_settings.popups": 0,
"download.default_directory": r""+Constants.path+"",
# IMPORTANT - ENDING SLASH V IMPORTANT
"directory_upgrade": True}
options.add_experimental_option("prefs", preferences)
driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)
Run Code Online (Sandbox Code Playgroud)
使用相同的代码,我可以在本地计算机(即笔记本电脑)上运行此代码,但此代码无法在我的虚拟机上运行。两台机器上的 chrome 版本相同,即 - 109.0.5414.120。
请指导。
google-chrome python-3.x selenium-webdriver webdriver-manager webdrivermanager-python
我是网络抓取的新手,我正在尝试使用以下几行修改我的用户代理:
from selenium import webdriver
chrome_path = r'C:\Users\Desktop\chromedriver_win32\chromedriver.exe'
driver = webdriver.Chrome(chrome_path)
options = webdriver.ChromeOptions()
options.add_argument('user-agent = Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36')
driver = webdriver.Chrome(chrome_options=options)
Run Code Online (Sandbox Code Playgroud)
环境变量中的路径没问题,但我一直收到此错误消息:
File "C:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in startstdin=PIPE)
File "C:\Users\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py",line 709, in __init__restore_signals, start_new_session)
File "C:\Users\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py",line 997, in _execute_child startupinfo).
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\safia\AppData\Local\Programs\Python\Python36-32\Test 3- User Agent.py", line 9, in <module>
driver = webdriver.Chrome(chrome_options=options)
File "C:\Users\safia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__ …Run Code Online (Sandbox Code Playgroud) python selenium google-chrome selenium-chromedriver selenium-webdriver
我正在尝试使用 python 和 selenium 自动化我的 Web 应用程序,我面临以下问题。
环境 - Mac/Python/Selenium IDE - PyCharm
selenium.common.exceptions.WebDriverException: 消息:'chromedriver' 可执行文件需要在 PATH 中。请参阅 https://sites.google.com/a/chromium.org/chromedriver/home
请帮我解决这个问题。
当我运行脚本时,出现此错误
Traceback (most recent call last):
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 992, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/ishaq/AppData/Local/Programs/Python/Python36/headless.py", line 9, in <module>
driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver"), chrome_options=chrome_options)
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
self.service.start()
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: …Run Code Online (Sandbox Code Playgroud) python selenium headless selenium-chromedriver google-chrome-headless
selenium ×11
python ×10
linux ×2
firefox ×1
geckodriver ×1
headless ×1
pycharm ×1
python-3.x ×1