0

I want to be able to select the button that has the timestamp i am targeting. Here is the HTML:

<a class="mdc-button mdc-button--unelevated mdc-ripple-upgraded" href="#" onclick="selectTime(7160, null, &quot;2021-08-23T08:15:00-04:00&quot;, '8b96beed5b0b8f7b34e51853f14ef6eb'); return false;" style="--mdc-ripple-fg-size:55px; --mdc-ripple-fg-scale:1.97805; --mdc-ripple-fg-translate-start:17px, -19.5px; --mdc-ripple-fg-translate-end:18.5px, -9.5px;">
                    <div class="mdc-button__ripple"></div>
                    <span class="mdc-button__label">8:15 AM</span>
                </a>

I do not know how to target the timestamp parameter it is calling in onclick that can be used to select the button. I have tried to find element by targeting the label's text, but I cannot click on the label, with it giving me this error :

Message: element click intercepted: Element <span class="mdc-button__label">...</span> is not clickable at point (132, 380). Other element would receive the click: <div class="mdc-button__ripple"></div>

Any help would be greatly appreciated.

1 Answer 1

1

You can use the below css_selector :

a[class$='mdc-ripple-upgraded'] span[class='mdc-button__label']

use it like this :

wait = WebDriverWait(driver, 10)
ActionChains(driver).move_to_element(wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a[class$='mdc-ripple-upgraded'] span[class='mdc-button__label']")))).click().perform()

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
10
  • where do I specify the text of the label? Aug 23, 2021 at 4:55
  • You don't need to, Do you just wanna click on the button ? Also text can change right in future? Aug 23, 2021 at 4:56
  • sorry to clarify it's a list of buttons, each with a unique text label; how can I select the outter button based on the nested span element's text? Aug 23, 2021 at 4:57
  • okay I thought time text would change, anyway if it's unique try using this xpath //span[text()='8:15 AM']/.. use it like ActionChains(driver).move_to_element(wait.until(EC.visibility_of_element_located((By.XPATH, "//span[text()='8:15 AM']/..")))).click().perform() Aug 23, 2021 at 4:59
  • oh sorry it does change, the times change everyday, anyway I can do partial text in that method? Aug 23, 2021 at 5:00

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.