AnsonLai / TeslaServiceManualScraper

This script will download the Tesla Service Manual onto a local doc folder for offline access.
MIT License
65 stars 12 forks source link

AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector' #9

Closed ZachSandhofer closed 2 years ago

ZachSandhofer commented 2 years ago

Chrome 103, is this a chrome driver problem?

C:\Program Files\Python310\TeslaServiceManualScraper-master>py scrape.py C:\Program Files\Python310\TeslaServiceManualScraper-master\scrape.py:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives from distutils.command.clean import clean

DevTools listening on ws://127.0.0.1:54174/devtools/browser/3f8df9b0-340b-4578-ac26-aa680caabf37 ** SESSION LOADED ** Traceback (most recent call last): File "C:\Program Files\Python310\TeslaServiceManualScraper-master\scrape.py", line 272, in run() File "C:\Program Files\Python310\TeslaServiceManualScraper-master\scrape.py", line 261, in run driver.get_index() File "C:\Program Files\Python310\TeslaServiceManualScraper-master\scrape.py", line 46, in get_index driver = tesla_login(self.driver) File "C:\Program Files\Python310\TeslaServiceManualScraper-master\secrets.py", line 10, in tesla_login driver.find_element_by_css_selector("#form-input-identity").send_keys(tesla_account_email) AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector'

AnsonLai commented 2 years ago

Hey there, this typically happens when Tesla throws up a non-standard login page, such as one that includes a captcha. I'd shut it down, try it again in 10 minutes.

ZachSandhofer commented 2 years ago

I tried waiting and clearing everything and still get this error. Seems to redirect from the driver.get link to this. Still same result.

Any ideas what might be happening? Tried with VPN as well, but no luck. I still can log in normally with no issues to the service manuals.

Nakirasu commented 2 years ago

I stumble on the same error. Turns out, selenium removed the method find_elementby* starting version 4.3.0.

https://github.com/SeleniumHQ/selenium/blob/trunk/py/CHANGES

Selenium 4.3.0
* Deprecated find_element_by_* and find_elements_by_* are now removed (#10712)
* Deprecated Opera support has been removed (#10630)
* Fully upgraded from python 2x to 3.7 syntax and features (#10647)
* Added a devtools version fallback mechanism to look for an older version when mismatch occurs (#10749)
* Better support for co-operative multi inheritance by utilising super() throughout
* Improved type hints throughout

I had to downgrade as a workaround :

First uninstall the current version pip uninstall selenium

Install the version 4.2.0 or older pip install selenium==4.2.0

ZachSandhofer commented 2 years ago

Resolved with a reinstall of selenium 4.2.0