kaliiiiiiiiii / Selenium-Profiles

undetected Selenium using chromedriver and emulation / device profiles
Other
272 stars 29 forks source link

Chromedriver version missmatch in new project on macOS #64

Closed nradosevic closed 1 year ago

nradosevic commented 1 year ago

Describe the bug I made a new project, installed the library and tried to run demo code but I got this exception:

"/Users/nikola/IT Projects/selenium_profiles_test3/venv/bin/python" /Users/nikola/IT Projects/selenium_profiles_test3/main.py Traceback (most recent call last): File "/Users/nikola/IT Projects/selenium_profiles_test3/main.py", line 10, in driver = Chrome(profile, options=options, base_drivers=(webdriver.Chrome,), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/selenium_profiles/webdriver.py", line 140, in init super().init(*kwargs) File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/seleniumwire/webdriver.py", line 218, in init super().init(args, **kwargs) File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/selenium/webdriver/chrome/webdriver.py", line 49, in init super().init( File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.py", line 54, in init super().init( File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 206, in init self.start_session(capabilities) File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 291, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 346, in execute self.error_handler.check_response(response) File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/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 111 Current browser version is 114.0.5735.198 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome Stacktrace: 0 chromedriver 0x00000001025fad3c chromedriver + 4222268 1 chromedriver 0x00000001025818e8 chromedriver + 3725544 2 chromedriver 0x0000000102237da4 chromedriver + 277924 3 chromedriver 0x0000000102262960 chromedriver + 452960 4 chromedriver 0x000000010225e918 chromedriver + 436504 5 chromedriver 0x000000010225b91c chromedriver + 424220 6 chromedriver 0x000000010229be10 chromedriver + 687632 7 chromedriver 0x000000010229b590 chromedriver + 685456 8 chromedriver 0x00000001022658f0 chromedriver + 465136 9 chromedriver 0x0000000102266974 chromedriver + 469364 10 chromedriver 0x00000001025cb788 chromedriver + 4028296 11 chromedriver 0x00000001025cfc1c chromedriver + 4045852 12 chromedriver 0x00000001025d5c98 chromedriver + 4070552 13 chromedriver 0x00000001025d08d8 chromedriver + 4049112 14 chromedriver 0x00000001025a7d84 chromedriver + 3882372 15 chromedriver 0x00000001025ee720 chromedriver + 4171552 16 chromedriver 0x00000001025ee878 chromedriver + 4171896 17 chromedriver 0x0000000102602014 chromedriver + 4251668 18 libsystem_pthread.dylib 0x00000001c356426c _pthread_start + 148 19 libsystem_pthread.dylib 0x00000001c355f08c thread_start + 8

Process finished with exit code 1

My macOS version is 12.5

To Reproduce Make a new project Install using pip install selenium-profiles Run the demo code

Environment (please complete the following information): macOS 12.5 Monterey Python 3.11

nradosevic commented 1 year ago

And when i tried to se the UC flag to True I got a different erorr:

"/Users/nikola/IT Projects/selenium_profiles_test3/venv/bin/python" /Users/nikola/IT Projects/selenium_profiles_test3/main.py /Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/selenium_profiles/webdriver.py:51: UserWarning: More than one base_driver might not initialize correctly, seems buggy. Also, you might try different order warnings.warn("More than one base_driver might not initialize correctly, seems buggy.\n Also, you might try different order") Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 1348, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 1286, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 1332, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 1281, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 1041, in _send_output self.send(msg) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 979, in send self.connect() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 1458, in connect self.sock = self._context.wrap_socket(self.sock, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 517, in wrap_socket return self.sslsocket_class._create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 1075, in _create self.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 1346, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/nikola/IT Projects/selenium_profiles_test3/main.py", line 10, in driver = Chrome(profile, options=options, base_drivers=(webdriver.Chrome,), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/selenium_profiles/webdriver.py", line 140, in init super().init(*kwargs) File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/undetected_chromedriver/init.py", line 247, in init self.patcher.auto() File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/undetected_chromedriver/patcher.py", line 158, in auto release = self.fetch_release_number() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nikola/IT Projects/selenium_profiles_test3/venv/lib/python3.11/site-packages/undetected_chromedriver/patcher.py", line 222, in fetch_release_number return LooseVersion(urlopen(self.url_repo + path).read().decode()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 216, in urlopen return opener.open(url, data, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 519, in open response = self._open(req, data) ^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 536, in _open result = self._call_chain(self.handle_open, protocol, protocol + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 496, in _call_chain result = func(args) ^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 1391, in https_open return self.do_open(http.client.HTTPSConnection, req, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 1351, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)>

Process finished with exit code 1

nradosevic commented 1 year ago

I'm sorry, it seems to me that the second issue is related to undetected chromedriver

nradosevic commented 1 year ago

The second error when using UC was just related to the fact that I was using fresh python 3.11 and I needed to manually install certificates for python like this: https://stackoverflow.com/questions/42098126/mac-osx-python-ssl-sslerror-ssl-certificate-verify-failed-certificate-verify

kaliiiiiiiiii commented 1 year ago

You basically need to download the driver manually then.

I suppose that this issue isn't Selenium-Profiles it's fault, and rather Selenium itsself.

You can try the following:

from webdriver_manager.chrome import ChromeDriverManager

from selenium_profiles.webdriver import Chrome
from selenium_profiles.profiles import profiles
from selenium.webdriver.common.by import By  # locate elements
from seleniumwire import webdriver

profile = profiles.Windows() # or .Android
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
driver = Chrome(profile, options=options, executable_path=ChromeDriverManager(version="114.0.5735.16").install(),
                uc_driver=False
                )

# get url
driver.get('https://abrahamjuliot.github.io/creepjs/')  # test fingerprint

input("Press ENTER to exit: ")
driver.quit()  # Execute on the End!

or directly download from ChromeDriver 114.0.5735.16

see available versions

Note: If this resolves your issue, please close it

nradosevic commented 1 year ago

But I thought that selenium profiles handles the webdriver download if UC flag is set to false , nit Selenium itself? (for UC case see my other messages, it was a different error and I solved it by manually installing certificates for python 11)

Or maybe that 111 chromedriver was there from before, I will check again.

Is the lib suppposed to fetch the appropriate chromedriver if UC flag is set to false?

kaliiiiiiiiii commented 1 year ago

But I thought that selenium profiles handles the webdriver download if UC flag is set to false , nit Selenium itself? (for UC case see my other messages, it was a different error and I solved it by manually installing certificates for python 11)

Yeah, thearetically, Selenium should to that independend. But seems like it's not that reliable

Or maybe that 111 chromedriver was there from before, I will check again.

Yeah, you might check files within $PATH

Is the lib suppposed to fetch the appropriate chromedriver if UC flag is set to false?

executable_path=ChromeDriverManager(version="114.0.5735.16").install() should always be working, no mattter if uc_driver is True or False

@nradosevic Does this resolve your issue?

kaliiiiiiiiii commented 1 year ago

@nradosevic closing for now because of inactivity, feel free to tell if this issue still persists