使用selenium时,如何修复程序中的此错误/问题



几个月前,我制作了一个程序,将您重定向到谷歌chrome上的某个网站(我安装了一个chrome驱动程序,因此Selenium将适用于谷歌chrome(。当我多次测试时,一切都很正常,但后来我不得不专注于学校,所以我推迟了项目的完成。所以几天前,我有一些空闲时间;所以我用它来尝试完成我正在进行的程序,所以我运行了这个程序,结果总是出现这个错误:

Traceback (most recent call last):
File "/Users/boogytoogy/Desktop/Programming /Python/Other.py", line 25, in <module>
driver = webdriver.Chrome()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 266, in __init__
self.start_session(capabilities, browser_profile)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 357, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 418, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 89
Current browser version is 95.0.4638.69 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Stacktrace:
0   chromedriver                        0x0000000104c7cb59 chromedriver + 2595673
1   chromedriver                        0x0000000105330b33 chromedriver + 9624371
2   chromedriver                        0x0000000104a2c773 chromedriver + 169843
3   chromedriver                        0x0000000104a50bf6 chromedriver + 318454
4   chromedriver                        0x0000000104a4cdc4 chromedriver + 302532
5   chromedriver                        0x0000000104a4a032 chromedriver + 290866
6   chromedriver                        0x0000000104a7d234 chromedriver + 500276
7   chromedriver                        0x0000000104a784f3 chromedriver + 480499
8   chromedriver                        0x0000000104a52cd6 chromedriver + 326870
9   chromedriver                        0x0000000104a53ba7 chromedriver + 330663
10  chromedriver                        0x0000000104c4ab09 chromedriver + 2390793
11  chromedriver                        0x0000000104c57bcc chromedriver + 2444236
12  chromedriver                        0x0000000104c576ee chromedriver + 2442990
13  chromedriver                        0x0000000104c31832 chromedriver + 2287666
14  chromedriver                        0x0000000104c5863f chromedriver + 2446911
15  chromedriver                        0x0000000104c40299 chromedriver + 2347673
16  chromedriver                        0x0000000104c6f8b9 chromedriver + 2541753
17  chromedriver                        0x0000000104c82008 chromedriver + 2617352
18  libsystem_pthread.dylib             0x00007fff204f28fc _pthread_start + 224
19  libsystem_pthread.dylib             0x00007fff204ee443 thread_start + 15

所以很明显,我一直在努力修复这个程序的错误。我试过卸载chrome驱动程序和selenium模块,但都无济于事。所以你能帮我纠正这个错误吗。谢谢

代码:

from selenium import webdriver
import time
import sys
def welcome():
global variables
print("Welcome to the Multi-Method Quiz")                    #I will be testing the features of the program
time.sleep(2)
print("Choose what you want to play, you will have 10 minutes time to finish either of those")
time.sleep(4)
print("A Quiz on Quizizz(1) or simple true or false quiz(2)")
try:
opts = int(input("option 1 or option 2: "))
except ValueError:
print("No number detected")
if opts != 1 and opts != 2:
while True:
print("Invalid, Please Re-run the Program")
break
def options():
global variables
if opts == 1:
print("You will be redirected to the website, then simply press Play to start the quiz")
driver = webdriver.Chrome()
driver.get("https://quizizz.com/join/quiz/5d77ea5699886d0020d1f3ad/start")
time.sleep(600)
driver.quit()

您有chromedriver版本89,它很旧,与您当前的chrome浏览器版本95.0.4638.69不匹配。请更新您的chromedriver。

我建议使用以下方法,这样你就不必每次更新chromedriver了。

在Python 中自动下载适用于硒的合适的chromedriver

相关内容

  • 没有找到相关文章

最新更新