1

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)

2 Answers2

0

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

Prophet
  • 32,350
  • 22
  • 54
  • 79
0

Usually this happens when the wanted element is covered partially or completely by another element(a an alert message or some floating element).

It says so in the error message also: Other element would receive the click: <span _ngcontent-oyq-c4="" class="sessionTimeHeading">...</span>

So the first thing to do is make sure this element is either removed (by clicking the alert) or that the resolution of the screen is wide enough to be able to click the required element.