Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Shutting down at Starting Application process #1054

Open
jbatra215 opened this issue Jan 16, 2025 · 4 comments
Open

[BUG]: Shutting down at Starting Application process #1054

jbatra215 opened this issue Jan 16, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@jbatra215
Copy link

jbatra215 commented Jan 16, 2025

Describe the bug

The system comes to Starting Application process and stops working and then shuts down the browser

(myenv) C:\Users\JB\LinkedIn_AIHawk_automatic_job_application>python main.py
Starting Chrome browser to log in to LinkedIn.
Starting the search for Software developer in Germany.
Going to job page 0
Starting the application process for this page...

(myenv) C:\Users\JB\LinkedIn_AIHawk_automatic_job_application>

use below script to Steps to reproduce

below is my linkedin Authenticator.py

import time
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class LinkedInAuthenticator:

def __init__(self, driver=None):
    self.driver = driver
    self.email = ""
    self.password = ""

def set_secrets(self, email, password):
    self.email = email
    self.password = password

def start(self):
    """Start the Chrome browser and attempt to log in to LinkedIn."""
    print("Starting Chrome browser to log in to LinkedIn.")
    self.driver.get('https://www.linkedin.com')
    self.wait_for_page_load()
    if not self.is_logged_in():
        self.handle_login()

def handle_login(self):
    """Handle the LinkedIn login process."""
    print("Navigating to the LinkedIn login page...")
    self.driver.get("https://www.linkedin.com/login")
    try:
        self.enter_credentials()
        self.submit_login_form()
    except NoSuchElementException:
        print("Could not log in to LinkedIn. Please check your credentials.")
    time.sleep(3) #TODO fix better
    self.handle_security_check()

def enter_credentials(self):
    """Enter the user's email and password into the login form."""
    try:
        email_field = WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located((By.ID, "username"))
        )
        email_field.send_keys(self.email)
        password_field = self.driver.find_element(By.ID, "password")
        password_field.send_keys(self.password)
    except TimeoutException:
        print("Login form not found. Aborting login.")

def submit_login_form(self):
    """Submit the LinkedIn login form."""
    try:
        login_button = self.driver.find_element(By.XPATH, '//button[@type="submit"]')
        login_button.click()
    except NoSuchElementException:
        print("Login button not found. Please verify the page structure.")

def handle_security_check(self):
    """Handle LinkedIn security checks if triggered."""
    try:
        WebDriverWait(self.driver, 4).until(
            EC.url_contains('https://www.linkedin.com/checkpoint/challengesV2/')
        )
        print("Security checkpoint detected. Please complete the challenge.")
        WebDriverWait(self.driver, 4).until(
            EC.url_contains('https://www.linkedin.com/feed/')
        )
        print("Security check completed")
    except TimeoutException:
        print("Security check not completed. Please try again later.")

def is_logged_in(self):
    """Check if the user is already logged in to LinkedIn."""
    self.driver.get('https://www.linkedin.com/feed')
    time.sleep(3)  # Give more time for the page to load
    try:
        # Try multiple selectors to verify login status
        logged_in_selectors = [
            (By.CLASS_NAME, 'share-box-feed-entry__trigger'),
            (By.CSS_SELECTOR, '[data-control-name="share.post"]'),
            (By.CSS_SELECTOR, '.global-nav__me-photo'),
            (By.CSS_SELECTOR, '.feed-identity-module__member-photo')
        ]
        
        for selector_type, selector in logged_in_selectors:
            try:
                element = WebDriverWait(self.driver, 2).until(
                    EC.presence_of_element_located((selector_type, selector))
                )
                if element:
                    return True
            except TimeoutException:
                continue
                
    except TimeoutException:
        pass
    return False

def wait_for_page_load(self, timeout=2):
    """Wait for the page to fully load."""
    try:
        WebDriverWait(self.driver, timeout).until(
            lambda d: d.execute_script('return document.readyState') == 'complete'
        )
    except TimeoutException:
        print("Page load timed out.")

Expected behavior

system to start applying jobs

Actual behavior

the browser shut down

Branch

main

Branch name

main

Python version

3.10

LLM Used

openai

Model used

GPT-40

Additional context

No response

@jbatra215 jbatra215 added the bug Something isn't working label Jan 16, 2025
@charuagrawal1980
Copy link

Hi, How did you get the job applier to start? When I run this using
python main.py --resume.pdf, it gives me following 3 options and stops after generating resume. Am I running an incorrect file?

"Generate Resume",
"Generate Resume Tailored for Job Description",
"Generate Tailored Cover Letter for Job Description",

@jbatra215
Copy link
Author

Hi, How did you get the job applier to start? When I run this using python main.py --resume.pdf, it gives me following 3 options and stops after generating resume. Am I running an incorrect file?

"Generate Resume", "Generate Resume Tailored for Job Description", "Generate Tailored Cover Letter for Job Description",

I have a two installations on two different computers one of my computer has the same behavior but when I installed it on my other computer I have the new behavior where it opens the LinkedIn and start searching for the file I think the difference is the secrets file where I now put my LinkedIn Authentication I think the other thing that I did was I actually downloaded a second pair of files from the GitHub directly and the second pair of files had a file called LinkedIn Authenticator and other LinkedIn files try that and let me know if you need any other help from me

@khoahuynh0110
Copy link

The bot is shutting down, no longer working since LinkedIn updated and also they are banned!

@jbatra215
Copy link
Author

jbatra215 commented Jan 18, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants