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 'People'.
This is the HTML element:
<button aria-checked="false" role="button" aria-label="Locations filter. Clicking this button displays all Locations filter options."
id="ember745" class="artdeco-pill artdeco-pill--slate artdeco-pill--2 artdeco-pill--choice ember-view search-reusables__filter-pill-button" aria-controls="artdeco-hoverable-artdeco-gen-54" aria-expanded="false" data-control-name="filter_top_bar_select" type="button">
Locations
<!----> <li-icon aria-hidden="true" type="caret-filled-down-icon" class="search-reusables__pill-button-caret-icon" size="small"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" data-supported-dps="16x16" fill="currentColor" class="mercado-match" width="16" height="16" focusable="false">
<path d="M8 11L3 6h10z" fill-rule="evenodd"></path>
</svg></li-icon>
</button>
These are the different codes that I've tried till now. Mind you, I can't select by id because LinkedIn is changing the ember number ID every few minutes.
locations = browser.find_element_by_xpath('//*[@class="artdeco-pill artdeco-pill--slate artdeco-pill--2 artdeco-pill--choice ember-view search-reusables__filter-pill-button"]')
locations = browser.find_element_by_xpath('//div[@aria-label="Locations filter. Clicking this button displays all Locations filter options."]')
locations = browser.find_element_by_xpath("//div[@aria-label='Locations filter. Clicking this button displays all Locations filter options.']/div[@class='artdeco-pill artdeco-pill--slate artdeco-pill--2 artdeco-pill--choice ember-view search-reusables__filter-pill-button' and text()='Locations']")
locations = browser.find_element_by_xpath('(//div[@class="artdeco-pill artdeco-pill--slate artdeco-pill--2 artdeco-pill--choice ember-view search-reusables__filter-pill-button"])[3]')
locations = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'artdeco-pill artdeco-pill--slate artdeco-pill--2 artdeco-pill--choice ember-view search-reusables__filter-pill-button')))
I've spent a lot of time on this but haven't found a solution yet.
After clicking on Location, I also want to select United States and then click on Company Name and write a company name.
Next part: This is the html for 'United States' location. I want to click on 'United States' and search for that filter.
<li class="search-reusables__collection-values-item">
<input aria-label="Filter by United States" name="United States" id="geoUrn-103644278" class="search-reusables__select-input" data-control-name="filter_detail_select" type="checkbox" value="103644278">
<label for="geoUrn-103644278" class="search-reusables__value-label">
<p class="display-flex">
<span class="t-14 t-black--light t-normal">
United States
</span>
</p>
</label>
<!----> </li>
I tried this code but it didn't do anything:
unitedstates = WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.XPATH, '//li//input[contains(@aria-label,"Filter by United States")]')))
unitedstates.click()
