Issue
Xpath / Full Xpath is not allowing me to access Easy Apply in the LinkedIn bot. enter image description here
try:
easy_apply = self.driver.find_element(By.XPATH, '//*[@id="+Yx8O6UNSU67JGJE1z0tug=="]/div/ul[1]/li[2]/a')
easy_apply.click()
print("Easy Apply - successfully triggered")
time.sleep(2)
except:
print("Error Can't hold the Easy apply.")
Solution
search for the "easy apply" button via text
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
# Create a WebDriver instance (e.g., Chrome)
driver = webdriver.Chrome()
# Open a web page
driver.get("https://example.com")
try:
# Find the button/anchor with case-insensitive text "Easy Apply"
easy_apply = driver.find_element(By.XPATH, "//a[contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'easy apply')]")
# Click the button
easy_apply.click()
# Log Success
print("Easy Apply - successfully triggered")
time.sleep(2)
except:
# Log Error
print("Error Can't hold the Easy apply.")
# Close the WebDriver when done
driver.quit()
Answered By - Dean Van Greunen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.