我正在使用以下網站:www.offerte.smartpaws.ch
我正在嘗試使用法語網站:www.offerte.smartpaws.ch/fr
我有一段代碼適用于德語部分,但由于某種原因,我在嘗試在法語方面做同樣的事情時遇到錯誤,即使元素是相同的。
我有以下代碼來選擇年份:
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()
這段代碼應該是經過一個年份的范圍,點擊日歷選項,然后點擊年份的下拉選單,選擇年份,最后,我們關閉日歷。
此方法在德國方面運行良好,但在法國方面失敗,并出現以下錯誤:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <input type="text" name="form-0-dob" id="id_form-0-dob" readonly="" class="picker__input" 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>
感謝您的任何建議或建議。
uj5u.com熱心網友回復:
嘗試div單擊input. 似乎對兩種語言網站都適用:
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="id_form-0-dob"]/..'))).click()
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/457816.html
