NathanDuma / LinkedIn-Easy-Apply-Bot

Automate LinkedIn Easy Apply job applications and answer application-specific questions.
223 stars 84 forks source link

Selenium NoSuchElementException: Message: no such element #35

Open voidbydefault opened 2 years ago

voidbydefault commented 2 years ago

Hi, I am stuck on this issue:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".jobs-search-results"}

I thought the page is loading too fast hence adding a delay may help so I added 'driver.implicitly_wait(10)' in:

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

    for option in options:
        browser_options.add_argument(option)

    #driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=browser_options)
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=browser_options)

    driver.set_window_position(0, 0)
    driver.maximize_window()
    #added delay to avoid 'method' not found error
    driver.implicitly_wait(10)

    return driver

Unfortunately, it didn't help. Any ideas? Thanks.

voidbydefault commented 2 years ago

Small update. I tried same config.yaml on another account (only difference is email and password, rest of the config remained same), and the bot was working fine. When I revert back to the first account -- again same config.yaml except email/password, it started to throw exceptions as follows (copying all output). Both accounts are working normally with easy apply working.

Starting the search for trainee in Brampton, Ontario, Canada.
Going to job page 0
Starting the application process for this page...
Traceback (most recent call last):
  File "/home/me/Documents/LinkedIn-Easy-Apply-Bot/linkedineasyapply.py", line 124, in apply_jobs
    job_results = self.browser.find_element_by_class_name("jobs-search-results")
  File "/home/me/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 766, in find_element_by_class_name
    return self.find_element(by=By.CLASS_NAME, value=name)
  File "/home/me/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 1251, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "/home/me/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 430, in execute
    self.error_handler.check_response(response)
  File "/home/me/.local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".jobs-search-results"}
  (Session info: chrome=102.0.5005.61)
Stacktrace:
#0 0x5568b16fcf33 <unknown>
#1 0x5568b1447118 <unknown>
#2 0x5568b147d3f7 <unknown>
#3 0x5568b147d5c1 <unknown>
#4 0x5568b14b05c4 <unknown>
#5 0x5568b149af9d <unknown>
#6 0x5568b14ae2e4 <unknown>
#7 0x5568b149ae63 <unknown>
#8 0x5568b147082a <unknown>
#9 0x5568b1471985 <unknown>
#10 0x5568b17414cd <unknown>
#11 0x5568b17455ec <unknown>
#12 0x5568b172b71e <unknown>
#13 0x5568b1746238 <unknown>
#14 0x5568b1720870 <unknown>
#15 0x5568b1762608 <unknown>
#16 0x5568b1762788 <unknown>
#17 0x5568b177cf1d <unknown>
#18 0x7f06386b2eae <unknown>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/Documents/LinkedIn-Easy-Apply-Bot/linkedineasyapply.py", line 81, in start_applying
    self.apply_jobs(location)
  File "/home/me/Documents/LinkedIn-Easy-Apply-Bot/linkedineasyapply.py", line 130, in apply_jobs
    raise Exception("No more jobs on this page")
Exception: No more jobs on this page
Sleeping for 896.2878136634827 seconds.
Citizen3rased commented 2 years ago

I found that jobs-search-results is not a class on the jobs page anymore, at least not for me. I had to change it to jobs-search-results-list. However, I am still having an issue where I see it scrolling down the jobs listings, but does not apply to any.

Citizen3rased commented 2 years ago

I had to make multiple changes between lines 125-129 such as for class names as follows to now have it applying to jobs, albeit very slowly:

    try:
        job_results = self.browser.find_element(By.CLASS_NAME, "jobs-search-results-list")
        self.scroll_slow(job_results)
        self.scroll_slow(job_results, step=300, reverse=True)

        job_list = self.browser.find_elements(By.CLASS_NAME, 'scaffold-layout__list-container')[0].find_elements(By.CLASS_NAME, 'jobs-search-results__list-item')
logix727 commented 1 year ago

I had to make multiple changes between lines 125-129 such as for class names as follows to now have it applying to jobs, albeit very slowly:

    try:
        job_results = self.browser.find_element(By.CLASS_NAME, "jobs-search-results-list")
        self.scroll_slow(job_results)
        self.scroll_slow(job_results, step=300, reverse=True)

        job_list = self.browser.find_elements(By.CLASS_NAME, 'scaffold-layout__list-container')[0].find_elements(By.CLASS_NAME, 'jobs-search-results__list-item')

does this still work?

to answer my question yes

xMacJ commented 1 year ago

The above code does not work anymore.