I’m trying to write a selenium script that is capable of clicking on the “Apply” button on a LinkedIn job posting such that the job posting is opened in a new tab in chrome.
However, it looks like LinkedIn doesn’t include the job posting link in it’s html at all.
If that’s the case, is my goal still achievable?
driver.get('https://www.linkedin.com/jobs/search?keywords=software%20engineer&location=United%20States')
job_block = driver.find_element(By.CLASS_NAME, "scaffold-layout__list-container")
jobs = job_block.find_elements(By.TAG_NAME, "li")
n = len(jobs)
i = 0
while i < n:
driver.implicitly_wait(0.5)
jobs = job_block.find_elements(By.TAG_NAME, "li")
n = len(jobs)
i += 1
# f.write(str(len(jobs)) + 'n')
if i < n:
ActionChains(driver).double_click(jobs[i]).perform()
driver.implicitly_wait(0.5)
driver.switch_to.window(driver.window_handles[-1])
d1 = driver.find_element(By.CLASS_NAME, "jobs-search__job-details--wrapper")
d2 = d1.find_element(By.CLASS_NAME, "job-view-layout.jobs-details")
d3 = d2.find_element(By.CLASS_NAME, "t-14")
d4 = d3.find_element(By.CLASS_NAME, "mt5")
d5 = d4.find_element(By.CLASS_NAME, "display-flex")
d6 = d5.find_element(By.CLASS_NAME, "jobs-s-apply.jobs-s-apply--fadein.inline-flex.mr2")
driver.implicitly_wait(0.5)
try:
#f.write("tryingn")
#d7 = d6.find_element(By.CLASS_NAME, "jobs-apply-button--top-card")
#d7.find_element(By.XPATH, "//button").click()
button = d6.find_element(By.CLASS_NAME, "jobs-apply-button.artdeco-button.artdeco-button--icon-right.artdeco-button--3 artdeco-button--primary.ember-view")
button.click()
f.write('button clickedn')
except:
continue