Home > Software engineering >  Use python script to Easy Apply on linkedin using selenium
Use python script to Easy Apply on linkedin using selenium

Time:07-24

I am trying to get the script to run a loop where it clicks each job on the listing but keep getting error. For reference I am trying to follow THIS tutorial

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

username_input = "[email protected]"
password_imput = "password"

driver = webdriver.Chrome("C:/Users/JUAN/Documents/chromedriver/chromedriver.exe")
driver.get("https://www.linkedin.com/jobs/search/?f_AL=true&geoId=100446943&keywords=data analyst&location=Argentina")

sign_in_button = driver.find_element("link text","Sign in")
sign_in_button.click()

email_field = driver.find_element("id", "username")
email_field.send_keys(username_input)

password_field = driver.find_element("id","password")
password_field.send_keys(password_imput)
password_field.send_keys(Keys.ENTER)
time.sleep(3)
all_listings = driver.find_element("css selector","job-card-container--clickable")

for listing in all_listings:
    print("called")
    listing.click()
    time.sleep(2)

Getting this error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"job-card-container--clickable"} (Session info: chrome=103.0.5060.114)

CodePudding user response:

Try to substitute:

all_listings = driver.find_element("css selector","job-card-container--clickable")

with:

from selenium.webdriver.common.by import By
xpath = "//*[contains(@class,'job-card-container--clickable')]"
all_listings = driver.find_element(by=By.XPATH, value=xpath)

CodePudding user response:

  all_listings = driver.find_element("css selector","job-card-container--clickable")

Because I was using a find_element rather than find_elements (in plural) it wasn't iterable because it only contained one

all_listings = driver.find_elements("css selector",".job-card-container--clickable")

fixed it

  • Related