I am working with the following website: www.offerte.smartpaws.ch
I am trying to use the French site: www.offerte.smartpaws.ch/fr
I have a piece of code that works with the German part but for some reason I get an error when trying to do the same thing on the French side, even if the elements are identical.
I have the following code to select the year:
for year in range(21,12,-1):
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="id_form-0-dob"]'))).click()
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="id_form-0-dob_root"]/div/div/div/div/div[1]/select[1]'))).click()
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,'//select[@ and @aria-controls="id_form-0-dob_table"]//option[text()=' str(2000 year) ']'))).click()
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="id_form-0-dob_root"]/div/div/div/div/div[2]/button'))).click()
This code is supposed to go through a range of years, click on the calendar option, then click on the dropdown for years and take the selected year, finally, we close the calendar.
This method is working fine in the German side, but fails at the French side, with the following error:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <input type="text" name="form-0-dob" id="id_form-0-dob" readonly="" aria-haspopup="true" aria-expanded="false" aria-readonly="false" aria-owns="id_form-0-dob_root"> is not clickable at point (921, 572). Other element would receive the click: <label for="id_form-0-dob">...</label>
Thank you for any advice or sugestions.
CodePudding user response:
Try clicking the parent div
element of the input
. Seems to work for me for both language sites:
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="id_form-0-dob"]/..'))).click()