I'm trying to click a "Download All" button using Selenium in Python. Here's the relevant HTML from inspect:
<button title="" type="button" class="bds-button variant-primary" data-title="">Download All</button>
I've tried literally everything I can think of:
XPath:
driver.find_element(By.XPATH, "//button[text()='Download All']").click()
CSS Selector:
driver.find_element(By.CSS_SELECTOR, "button.bds-button.variant-primary").click()
Looping through all buttons:
buttons = driver.find_elements(By.TAG_NAME, "button")
for b in buttons:
print(f'Text: "{b.text.strip()}" | Class: {b.get_attribute("class")}')
if b.text.strip() == "Download All":
b.click()
Explicit waits:
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//button[text()='Download All']"))
).click()
Scrolling into view:
driver.execute_script("arguments[0].scrollIntoView(true);", button)
Checking for iframes using:
print(driver.find_elements(By.TAG_NAME, "iframe"))
Checking for shadow DOMs, but I don’t see any shadow roots.
What I know:
The button is visible in the browser.
The button is not inside an iframe.
The button does not appear to be in a shadow DOM.
The page is fully loaded before interaction.
There's no id attribute on the button.
Here is a screenshot of the html elements: enter image description here
$x("//button[text()='Download All']"), and make sure that only 1 element is returned. What happens when you useWebDriverWait? Do you get a timeout or some other error? Can you share the URL of the page? Something weird is going on.