Skip to content Skip to sidebar Skip to footer

Unable To Select The Linkedin 'locations' Button Using Python Selenium

I'm trying to click on the Locations dropdown in LinkedIn. You'll reach this section of the LinkedIn page by searching for something in the LinkedIn Search bar and then clicking on

Solution 1:

That specific button can be located with this XPath:

//span//button[contains(@aria-label,'Locations filter')]

So the element can be retrieved by

locations_btn = WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.XPATH, '//span//button[contains(@aria-label,"Locations filter")]')))

The "United States" location can be selected by

WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.XPATH, '//div[contains(@id,"locations-filter")]//li[@class="search-reusables__collection-values-item"]//span[contains(.,"United States")]'))).click()

Or if you want to click the checkbox you can use something like this:

WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.XPATH, '//div[contains(@id,"locations-filter")]//li[@class="search-reusables__collection-values-item" and .//span[contains(.,"United States")]]//input'))).click()

Post a Comment for "Unable To Select The Linkedin 'locations' Button Using Python Selenium"