Jobs_Applier_AI_Agent
Jobs_Applier_AI_Agent copied to clipboard
[BUG]: Shutting down at Starting Application process
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