madingess / EasyApplyBot

Automate LinkedIn Easy Apply job applications and answer application-specific questions.
GNU General Public License v3.0
101 stars 113 forks source link

Webdriver / Selenium deprecations. Code needs an update. #12

Closed voidbydefault closed 1 year ago

voidbydefault commented 1 year ago

Hi,

Chromium launches but gets stuck with word, "data:," in address bar without navigating to LinkedIn login page as specified in line 42 of linkedineasyapply.py hence login routine stalls causing unintended termination of session.

My environment:

I have tried running in venv as well using terminal. Issue persists.

Log:

/home/user/Documents/LinkedIn-Easy-Apply-Bot/main.py:16: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=browser_options)
/home/user/Documents/LinkedIn-Easy-Apply-Bot/main.py:16: DeprecationWarning: use options instead of chrome_options
  driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=browser_options)
Traceback (most recent call last):
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/main.py", line 123, in <module>
    browser = init_browser()
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/main.py", line 16, in init_browser
    driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=browser_options)
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/venv/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    super().__init__(
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 106, in __init__
    super().__init__(
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 288, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 381, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 444, in execute
    self.error_handler.check_response(response)
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 249, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
voidbydefault commented 1 year ago

Update: I added --remote-debugging-port=9222 to init_browser (main.py, line 10) as follows:

def init_browser():
    browser_options = Options()
    options = ['--disable-blink-features', '--no-sandbox', '--start-maximized', '--disable-extensions',
               '--ignore-certificate-errors', '--disable-blink-features=AutomationControlled', '--remote-debugging-port=9222']

But then... I am stuck here:

Traceback (most recent call last):
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/main.py", line 126, in <module>
    bot.login()
  File "/home/user/Documents/LinkedIn-Easy-Apply-Bot/linkedineasyapply.py", line 44, in login
    self.browser.find_element_by_id("username").send_keys(self.email)
AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'

It seems that something is changed either by LinkedIn or WebDriver.

voidbydefault commented 1 year ago

Second update:

It seems Webdriver guys were bored so they decided to deprecate a few things, now following works (we have to change the method, I am learning Python so please excuse my noobivity):

#self.browser.find_element_by_id("username").send_keys(self.email)
self.browser.find_element("id", "username").send_keys(self.email)

#self.browser.find_element_by_id("password").send_keys(self.password)
self.browser.find_element("id", "password").send_keys(self.password)

#self.browser.find_element_by_css_selector(".btn__primary--large").click()
self.browser.find_element(By.CSS_SELECTOR, ".btn__primary--large").click()

It seems you will have to update the code. Thanks.

madingess commented 1 year ago

Thanks for the detailed post.

Are you using the most recent version of this bot? These lines have been fixed already.

            self.browser.find_element(By.ID, "username").send_keys(self.email)
            self.browser.find_element(By.ID, "password").send_keys(self.password)
            self.browser.find_element(By.CSS_SELECTOR, ".btn__primary--large").click()

Please ensure you are using this repository and on the newest version:

git pull

Please reopen if issue persists.

voidbydefault commented 1 year ago

Thanks. I did try 'git pull' and it always reported up to date. Eventually, I deleted the folder and did 'git clone' again and things worked including new config.yaml.

I have created a pull request for minor fix for

def init_browser(): browser_options = Options() options = ['--disable-blink-features', '--no-sandbox', '--start-maximized', '--disable-extensions', '--ignore-certificate-errors', '--disable-blink-features=AutomationControlled', '--remote-debugging-port=9222']

madingess commented 1 year ago

That behavior by git is odd, but I am glad the reclone worked.

I currently do not see your pull request, but I will look out for it.

Thanks for following up.