Issue
I have code like this
for i in range(int(total_fill)):
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH,f'//*[@id="maincontentid"]/app-dashboard/app-itr-status/div[4]/div[{i+1}]/mat-card/div/div/div[4]/div[2]')))
b = driver.find_element_by_xpath(f'//*[@id="maincontentid"]/app-dashboard/app-itr-status/div[4]/div[{i+1}]/mat-card/div/div/div[4]/div[2]').click()
but i got this error :
ElementClickInterceptedException: Message: element click intercepted: Element <div _ngcontent-oyq-c49="" class="btnBox">...</div> is not clickable at point (753, 26). Other element would receive the click: <span _ngcontent-oyq-c4="" class="sessionTimeHeading">...</span>
(Session info: chrome=91.0.4472.114)
Solution
First of all try using element_to_be_clickable
instead of presence_of_element_located
.
If this still doesn't help you can use JavaClick
instead of driver.click()
.
So if this still will not work properly
for i in range(int(total_fill)):
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,f'//*[@id="maincontentid"]/app-dashboard/app-itr-status/div[4]/div[{i+1}]/mat-card/div/div/div[4]/div[2]')))
b = driver.find_element_by_xpath(f'//*[@id="maincontentid"]/app-dashboard/app-itr-status/div[4]/div[{i+1}]/mat-card/div/div/div[4]/div[2]').click()
try this:
for i in range(int(total_fill)):
el = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,f'//*[@id="maincontentid"]/app-dashboard/app-itr-status/div[4]/div[{i+1}]/mat-card/div/div/div[4]/div[2]')))
driver.execute_script("arguments[0].click();", el)
I have to notice: it is strongly not recommended to use such a complex locators like //*[@id="maincontentid"]/app-dashboard/app-itr-status/div[4]/div[{i+1}]/mat-card/div/div/div[4]/div[2]
they are extremely not reliably.
Also, please read here about the ElementClickInterceptedException
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.