Reputation: 395
I have an issue when trying to click this button in Selinium:
The folloying is the html code for each side:
"plus de 26 ans"
"Moins de 26 ans"
I have tride creating a button clicker by id using selenium (for first button):
btn_date = driver.find_element_by_id("radio-ins_age-above_26")
btn_date.click()
I get the error message that it is not clickable.
However, when viewing the html when I switch from one button to other I get the following change:
First button:
There is "::after::" that appears. When I click or press anything else it disappears.
How can I click this button?
Thanks
Upvotes: 1
Views: 30
Reputation: 33384
To click on dynamic element use WebDriverWait()
and wait for element to be clickable.
Use the following xpath
to click.
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//span[contains(.,'Plus de 26')]"))).click()
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//span[contains(.,'Moins de 26')]"))).click()
Import below libraries.
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
Upvotes: 1