I'm attempting to create an automation project that will go to the job section of linkedin, login, save the listing and follow the company for all the jobs on the page.
For the most part this seems to work but for some reason whenever I run the following code:
jobs = driver.find_elements(by=By.CSS_SELECTOR, value=".job-card-container--clickable")
Only the first 7 listings are identified out of 25. I've tried identifying them via other CSS, Class, Id elements but they bring up the same result.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
import time
# initial setup #
chrome_driver_path = Service("C:\chromedriver.exe")
driver = webdriver.Chrome(service=chrome_driver_path)
options = webdriver.ChromeOptions()
options.add_argument("--kiosk")
options.add_argument("--no-sandbox")
# driver.maximize_window()
driver.get("https://www.linkedin.com/jobs/search/?currentJobId=3271828611&keywords=python%20developer")
# Login #
time.sleep(1)
signin = driver.find_element(by=By.LINK_TEXT, value="Sign in")
signin.click()
time.sleep(1)
email = driver.find_element(by=By.ID, value="username")
email.send_keys("email@address.com")
password = driver.find_element(by=By.ID, value="password")
password.send_keys("password")
password.send_keys(Keys.ENTER)
time.sleep(5)
# Save reference #
jobs = driver.find_elements(by=By.CSS_SELECTOR, value=".job-card-container--clickable")
print(len(jobs))
# for job in jobs:
# job.click()
# time.sleep(2)
# save = driver.find_element(by=By.CLASS_NAME, value="jobs-save-button")
# scroll = driver.find_element(by=By.TAG_NAME, value="html")
#
# save.click()
# scroll.send_keys(Keys.END)
#
# time.sleep(2)
#
# follow = driver.find_element(by=By.CLASS_NAME, value="follow")
# follow.click()
Please find an image of the HTML elements I'm looking for on the webpage in the link below:
HTML elements I'm trying to find.
If anyone can let me know how to go about retrieving the full list of elements, it would be much appreciated.