0

I'm trying to click via find_element_by_xpath() as i did it always. In the case below, there is an error when try to click this element. I'm quite new with selenium and researched already. It seems that i have to click on specific coordination. Do you have any idea how to solve this problem? i'm struggling for quite a while.

section of HTML code:

<map ng-if="!enableSvgHighlighting" id="clickareasVillage" name="clickareasVillage" ng-show="areas.village.length > 0" class=""> <area ng-repeat="a in areas.village" location-id="32" on-pointer-over="highlightStart(32)" on- pointer-out="highlightStop(32)" clickable="openBuildingDialog(32)" tg- coords="758,341,758,342,761,343,763,344,767,345,769" coords="758,341,758,342,761,343,763,344,767,345,769" shape="poly" building-positioner="32" class="clickable"> 

my Code:

 WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//map[@id='clickareasVillage']/area[2]"))) ele1=driver.find_element_by_xpath("//map[@id='clickareasVillage']/area[2]") ele1.click() 

error message:

ElementClickInterceptedException: element click intercepted: Element <area ng-repeat="a in areas.village" location-id="32" on-pointer-over="highlightStart(32)" on-pointer-out="highlightStop(32)" clickable="openBuildingDialog(32)" tg-coords="758,341,758,342,761,343,763,344,767,345,769" coords="758,341,758,342,761,343,763,344,767,345,769" shape="poly" building-positioner="32" class="clickable"> is not clickable at point (391, 477). Other element would receive the click: <img ng-if="!enableSvgHighlighting" ng-show="areas.village.length > 0" class="clickareas" src="layout/images/x.gif" usemap="#clickareasVillage" data-cmp-info="9"> 

on other treads at stackoverflow, people suggest to use the following line. If i try, there is a TimeoutExeption.

WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.XPATH, "//map[@id='clickareasVillage']/area[2]"))) 

    3 Answers 3

    2

    As said above, usually when you encounter this error it's because a pop-up or an invisible overlay is preventing the driver from clicking on your element.

    You said that JS clicking wasn't working either so i'm going to give you 2 quick workarounds that you can try:

    1. ActionChains to move and click on your element:
    from selenium.webdriver.common.action_chains import ActionChains ActionChains(driver).move_to_element(element).click().perform() 
    1. Send keys using ActionChains
    from selenium.webdriver.common.action_chains import ActionChains for i in range(#determine how much time): ActionChains(driver).send_keys(Keys.TAB).perform() #tab until element is selected ActionChains(driver).send_keys(Keys.ENTER).perform() #press enter to "click" on it 

    Let me know if that helped you.

      0

      Try using javascript

      element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//map[@id='clickareasVillage']/area[2]"))) driver.execute_script("arguments[0].click();", element) 
        0

        There may be something which could be preventing click on the element, check if any pop-up occuring.

          Start asking to get answers

          Find the answer to your question by asking.

          Ask question

          Explore related questions

          See similar questions with these tags.