1

I am new in Selenium, here is the error that i showed up

My code:

 def job_search(self):
        """This function goes to the 'Jobs' section and looks for all the jobs that match the keywords and location"""
    
        # Go to the LinkedIn job search page
        self.driver.get("https://www.linkedin.com/jobs")
    
        # Wait for the job search page to load fully
        WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.CSS_SELECTOR, ".jobs-search-box__text-input[aria-label='Search by title, skill, or company']")))
    
        # Search based on keywords and location
        search_keywords = self.driver.find_element(By.CSS_SELECTOR, ".jobs-search-box__text-input[aria-label='City, state, or zip code']")
        search_keywords.clear()
        search_keywords.send_keys(self.keywords)
    
        # Wait for the search location input field to be interactable
        search_location = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".jobs-search-box__input--location")))
        search_location.clear()
        search_location.send_keys(self.location)
        search_location.send_keys(Keys.RETURN)

Here is the error that i got


ElementNotInteractableException: element not interactable
  (Session info: chrome=114.0.5735.134)

I want to interact with "Search bar" in LinkedIN, but unfortunately the error welcomed me

With Me
  • 11
  • 2

1 Answers1

0

You were pretty close. The locator strategy you have used to identify the search box, doesn't identifies the Search Box uniquely. Rather it identifies total 3 elements.

3elements


Solution

To locate the clickable element and send a character sequence instead of presence_of_element_located()you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.jobs-search-box__text-input.jobs-search-box__keyboard-text-input[aria-label='Search by title, skill, or company'][aria-activedescendant]"))).send_keys(self.keywords)
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='jobs-search-box__text-input jobs-search-box__keyboard-text-input' and @aria-label='Search by title, skill, or company'][@aria-activedescendant]"))).send_keys(self.keywords)
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352