Reputation: 51
I am trying to scrape data from the 'Financial & Retirement' section of the following website via Selenium
: https://www.glassdoor.com/Benefits/Amazon-US-Benefits-EI_IE6036.0,6_IL.7,9_IN1.htm
. But to get any relevant data, I need to click on the 'Financial & Retirement' tab first (by default it opens up in the 'Insurance, Health & Wellness' tab).
The first span tag associated with 'Financial & Retirement' is:
<span data-brandviews="MODULE:n=ei-benefits-category:eid=6036:benefit_category_id=2" aria-selected="false" data-test="tabName-Financial & Retirement" id="2" role="tab" tabindex="-1" class="css-1lydi83 e1dy3s0i0" data-triggered-brandview="">
So far, I have tried the following but none work:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='2']"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='2'][contains(., 'Financial')]"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@data-test='tabName-Financial & Retirement']"))).click()
Upvotes: 0
Views: 279
Reputation: 9969
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=options)
driver.maximize_window()
wait = WebDriverWait(driver, 30)
driver.get("https://www.glassdoor.ca/Benefits/Amazon-US-Benefits-EI_IE6036.0,6_IL.7,9_IN1.htm")
wait.until(EC.element_to_be_clickable((By.XPATH, "//span[@id='2']"))).click()
It worked simply doing this with no errors.
Upvotes: 1