I attempted to create an automated popcat.click program to increase the site's score. However, Chrome started and immediately shut down, and the following error occurred.
PS C:\Users\Ellen\Downloads> & C:/Users/Ellen/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/Ellen/Downloads/popcat.py
DevTools listening on ws://127.0.0.1:2904/devtools/browser/41c450ae-985d-4b06-bc4e-013701ad43c0
Traceback (most recent call last):
File "c:\Users\Ellen\Downloads\popcat.py", line 12, in <module>
bs = webdriver.Chrome(options=co)
File "C:\Users\Ellen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\chrome\webdriver.py", line 84, in __init__
super().__init__(
File "C:\Users\Ellen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\chromium\webdriver.py", line 104, in __init__
super().__init__(
File "C:\Users\Ellen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 286, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\Ellen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 378, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\Ellen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "C:\Users\Ellen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, 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 114
Current browser version is 116.0.5845.188 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
Stacktrace:
Backtrace:
GetHandleVerifier [0x007DA813+48355]
(No symbol) [0x0076C4B1]
(No symbol) [0x00675358]
(No symbol) [0x006961AC]
(No symbol) [0x00691EF3]
(No symbol) [0x00690579]
(No symbol) [0x006C0C55]
(No symbol) [0x006C093C]
(No symbol) [0x006BA536]
(No symbol) [0x006982DC]
(No symbol) [0x006993DD]
GetHandleVerifier [0x00A3AABD+2539405]
GetHandleVerifier [0x00A7A78F+2800735]
GetHandleVerifier [0x00A7456C+2775612]
GetHandleVerifier [0x008651E0+616112]
(No symbol) [0x00775F8C]
(No symbol) [0x00772328]
(No symbol) [0x0077240B]
(No symbol) [0x00764FF7]
BaseThreadInitThunk [0x770F00C9+25]
RtlGetAppContainerNamedObjectPath [0x77237B1E+286]
RtlGetAppContainerNamedObjectPath [0x77237AEE+238]
Here's all of code.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
import time
co = Options()
co.add_experimental_option("detach", True)
co.add_argument("--disable-dev-shm-usage")
co.add_argument("--disable-gpu")
co.add_argument("--no-sandbox")
bs = webdriver.Chrome(options=co)
bs.get("https://popcat.click/")
while True:
bs.find_element(By.XPATH, '//*[@id="app"]/div').click()
time.sleep(0.01)
I accessed the ChromeDriver site, downloaded version 116... and ran it, but it didn't work
You can dynamically download the appropriate driver in code. The installation process will download the driver version that matches your installed Chrome browser version:
from selenium.webdriver import Chrome
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver import ChromeService, ChromeOptions
options = ChromeOptions()
options.add_argument('--headless')
service = ChromeService(ChromeDriverManager().install())
with Chrome(options=options, service=service) as driver:
print(service.path) # this is where the driver is located
Note:
ChromeOptions isn't necessary for this but is a typical setup