0

I have the following HTML, which I have to click

<button aria-label="Nur Ergebnisse für Inhalte anzeigen" id="ember912" class="search-vertical-filter__filter-item-button artdeco-button artdeco-button--muted artdeco-button--2 artdeco-button--tertiary ember-view" type="button">
<!---->
<span class="artdeco-button__text">
    Inhalte
</span>
</button>

id is dynamic.

I tried like this

WebDriverWait(driver, delay).until(
                EC.presence_of_element_located((By.XPATH, "//button[@aria-label='Nur Ergebnisse für Inhalte anzeigen']/button[@class='search-vertical-filter__filter-item-button artdeco-button artdeco-button--muted artdeco-button--2 artdeco-button--tertiary ember-view' and text()='Nur Ergebnisse für Inhalte anzeigen']"))).click()

and like this

WebDriverWait(driver, delay).until(
                EC.presence_of_element_located((By.XPATH, '//span[contains(text(), "Inhalte")'))).click()

and like this

WebDriverWait(driver, delay).until(
                EC.presence_of_element_located((By.XPATH, '//span[contains(text(), "Inhalte") and @class="artdeco-button__text"]'))).click()

but it does not work, I always get TimeoutException

Appreciate any help

1 Answer 1

1

Use the following xpath to click on the element.

WebDriverWait(driver, delay).until(EC.element_to_be_clickable((By.XPATH, "//button[@aria-label='Nur Ergebnisse fÞr Inhalte anzeigen' and contains(.,'Inhalte')]"))).click()

OR

WebDriverWait(driver, delay).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(@aria-label , 'Nur Ergebnisse') and contains(.,'Inhalte')]"))).click()

Note: If you get the timeout exceptions from above xpath as well then please check if there any iframe present on the webpage.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.