[フレーム]

Automation

Selenium WebDriver tutorial Step by Step

You are here: Home / Advance Selenium / How to solve Element is not clickable at point in Selenium

How to solve Element is not clickable at point in Selenium

by 58 Comments

[画像:element is not clickable at point(x,y)]

I was very happy when I was working with Firefox on Windows, but in my organization, I came across through a requirement where I had to execute test case mainly on Chrome browser. I faced Element is not clickable at point in Selenium and I solved using different ways.

If you want to start working with chrome then check below post to see how to work with Chrome browser.

How to execute Selenium Testcase in Chrome browser

[画像:Element is not clickable at point in Selenium]

I started automating test case and most of the test cases was working fine, but some of the test cases were failing due to below exception.

Element is not clickable at point in Selenium

I have seen a couple of exception while working with Selenium but this was a new exception for me so I was not sure how to solve this.

I have collected some of frequent occurring exception in Selenium, which might help you.

Different Scenario of Selenium Exception

I started debugging my test cases, tried so many hit and trial, and finally found some of the solutions so thought will share with others too.

The reason for the element is not clickable at point(x,y) exception.

Some of my observation was

  • It mostly happens in Chrome so if you are mostly working with Firefox or IE then you will not be getting this exception.
  • Chrome does not calculate the exact location of element
  • Chrome always click in the middle of Element.
  • Sometimes you will get this exception due to Sync issue also.

YouTube Video for same

[フレーム]

Solution that worked for me to Solve element is not clickable at point(x,y) exception

1-Updated chrome driver to latest one 2.15

2-Get the coordinate then click on the link or button

3-Try to click using Y coordinates

// Find an element
WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));
// Scroll the browser to the element's Y position
((JavascriptExecutor)driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().y+")");
// Click the element
elementToClick.click();

4-Try to click using X coordinates

// Find an element
WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));
// Scroll the browser to the element's X position
((JavascriptExecutor)driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().x+")");
// Click the element
elementToClick.click();

Selenium has a large number of option to handle single thing in multiple ways so in case you are facing any issue feel free to reach out. Comment below for any suggestion and feedback.

Keep visiting, have a nice day J

For More updates Learn Automation page

For any query join Selenium group- Selenium Group

Reader Interactions

Comments

  1. Perron Firmin says

    Hello Dear Mukesh,
    I hope you are well. I sent you a message by your E-mail about the last suggestion.

    Thanks in advance,

    Perron,

  2. Perron Firmin says

    Hello dear Mukesh,

    Many thanks for your response. I sent you an e-mail. But I would like to write the code to manage next page click.

    I see this program that makes the same things I want to make :

    def scrape():
    driver = webdriver.PhantomJS()
    driver.get(‘http://quotes.toscrape.com/js-onclick’)
    while True:
    sel = parsel.Selector(text=driver.page_source)
    for quote in sel.css(‘div.quote’):
    print({
    ‘text’: quote.css(‘span.text::text’).extract_first(),
    ‘author’: quote.css(‘span small::text’).extract_first(),
    ‘tags’: quote.css(‘div.tags a.tag::text’).extract(),
    })
    try:
    next_button = driver.find_element_by_css_selector(‘li.next > a’)
    next_button.click()
    except NoSuchElementException:
    break

    When I make inspect on this URL, I get the following code for next button :

    Next

    for my context, I don’t know how to select the element for the next page button click. You can see my code after inspect on my URL.



    Page suivante

    PLEASE, help me to fix this.

    Many thanks,

  3. Soheil says

    hi Mukesh,

    i have tried sooo many things but cannot continue as i am getting the error ” is not clickable at point (1811, 300). Other element would receive the click:…”

    i have tried with:
    1. add implicit wait (implicitlyWait(timeout, TimeUnit.SECONDS);
    2. use action with offset
    3. use javascriptexecutor with offset (scroll-to)
    4. execute java script with javascriptexecutor (executeScript(“document.getElementByxpath)

    only way it worked was (but not permanentely)
    – ((JavascriptExecutor) webDriver).executeScript(“document.getElementById(‘unique ID of MYBUTTON’).click();”);
    – my button does not have id. i added ID during runtime in chrome inspector (F12)

    could you please help me? Invensting now 2 days cannot continue with all solutions.

      • Soheil says

        Hello Mukesh,

        thanks for your response. with dynamic xpath you mean something like this, right:
        webDriver.findElement(By.xpath(“//*[@class=’xxclass Tagxx of MYBUTTON’]”)).click();

        I have used the inspector in Chrome to locate the parent tags and also tried to click on them but no outcome. my element does not have an ID and i cannot influence the implementation.

        Is there a way to click on an Element through javascriptexecutor to a control which has not an ID? I mean using javascriptexecutor with an xpath?

        Because this worked: I defined during runtime (in debug mode) an ID to the control with the chrome inspector and this line:

        ((JavascriptExecutor) webDriver).executeScript(“document.getElementById(‘test’).click();”);

        I tried with this and it says: no such function named getelementbyxpath.

        StringBuffer javaScript=new StringBuffer();
        javaScript.append(“document.getElementByxpath(“”);
        javaScript.append(“/html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div[1]/ul/li/catalog-product/div/div[2]/div[1]/div”);
        javaScript.append(“”).click();”);
        JavascriptExecutor executor = (JavascriptExecutor)webDriver;
        String javaScriptText = javaScript.toString();
        executor.executeScript(javaScriptText);

        Hope i am not providing tooo much information and confuse…

        thanks so far.
        bye
        Mohammad

        • Mukesh Otwani says

          Hi Soheil,

          Try this
          WebElement elem = webDriver.findElement(By.xpath(xpath));
          String js = “arguments[0].style.height=’auto’; arguments[0].style.visibility=’visible’;”;
          ((JavascriptExecutor)ldriver).executeScript(js, elem);
          elem.click();
          ElementHighlight.higtLight(ldriver, lxpath);

          • Soheil says

            Hi Mukesh,

            really appreciate your help. Thanks!

            with this below i get an exception:

            WebElement elem = webDriver.findElement(By.xpath( “//*[@class=’ng-binding’]”));
            String script = “arguments[0].style.height=’auto’; arguments[0].style.visibility=’visible’;”;
            ((JavascriptExecutor)webDriver).executeScript(script, elem);
            clickableAddProduct.click();

            Exception message: unknown error: Runtime.evaluate threw exception: SyntaxError: Invalid or unexpected token
            at line 3 (JavaScriptExecutor line)

  4. Raveendra says

    Hi Mukesh,

    Hope you are doing Great,

    Thanks for sharing Your knowledge with us,

    I am following Your selenium videos its Really nice and clear&Well Explained Each and every point

    I am NEW to selenium so,

    I have a Question

    Can we perform KeyBoard API (like downloading a file by using TAB operations) using PageObjectModel, i am able performing the DROPDOWNS so i just want to confirm weather we can r not,

    Thanks&Regards,
    Raveendra

  5. Akash says

    Hi mukesh, facing same issue Element is not clickable at point (514.5, 11.866668701171875). Other element would receive the click: . please reply to resolve, i have send you my script one week ago Awaiting for your reply.

  6. Anju says

    Hi Mukesh,

    I am new to Selenium in learning stage,i found most of your post helpful but stucked in the following exception.I tried all the possibilities suggested by you, still not able to click on calender to select the date.

    I am sharing my code, pls help

    WebElement elementToClick = driver.findElement(By.xpath(“.//*[@id=’vfb-8′”));
    ((JavascriptExecutor)driver).executeScript(“window.scrollTo(0,”+elementToClick.getLocation().x+”)”);
    elementToClick.click();

    I am using Google Chrome version 54.0.2840.59

  7. Rekha says

    Hi Mukesh, I am encountering the same error = System.InvalidOperationException : unknown error: Element is not clickable at point (752, 237).

    when I click on a link in Chrome browser. Can you please let me know the IJavaScriptExecutor syntax for the same in C#

  8. prashant jha says

    Sir, I am getting the error ” Element is not clickable at point (958, 7) in firefox ” Sometime it is working and sometime it is showing the above .can you give me the solution how to fix it?

  9. Bimlesh says

    Hi Mukesh,

    Kindly advise on this issue.

    Scenario: Login successfully to http://www.homeshop18.com and then choose “Samsung” from “Digital” Menu. The results are displayed and now from the “Brand” section (displayed at the left side of the page), I need to choose another brand called “Micromax” by SROLLING.

    I am trying to achieve this but no luck so far.

    My code:

    public void Browse_Samsung() throws Exception
    {
    WebDriverWait wait = new WebDriverWait(driver, 30);
    Actions act = new Actions(driver);
    act.moveToElement(Digital_Menu).perform();
    act.click(wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(“//*[@id=’CategoryMenu1′]//a[@title=’Samsung’]”)))).build().perform();

    WebElement Micromax = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(“//*[@id=’filter_1Option_21′]//a[@title=’GSM Mobile Phones – Micromax’]”)));

    ((JavascriptExecutor)driver).executeScript(“window.scrollTo(0,”+Micromax.getLocation().x+”)”);

    Micromax.click();

    }

    Error:

    org.openqa.selenium.TimeoutException: Timed out after 30 seconds waiting for visibility of element located by By.xpath: //*[@id=’filter_1Option_21′]//a[@title=’GSM Mobile Phones – Micromax’]
    Build info: version: ‘2.53.1’, revision: ‘a36b8b1cd5757287168e54b817830adce9b0158d’, time: ‘2016年06月30日 19:26:09’

  10. Manasi says

    I am facing the same issue in FF, but only when I am using xpath. It works fine when I am using the link text.

  11. shruthi says

    Hi Mukesh,

    Really your code helped me.I am trying to solve my problem from 2 days.but couldn’t do it.

    Thankyou so much.I am just beginner.Could you please explain me why we should use Java script in that code?

  12. Zaher says

    I have had this problem on FF. This issue happens when your field is not in the view area. The slick way to resolve this issue is to zoom out your browser:

    TheNotClickableField.SendKeys(Keys.Control + “-” + “-“);

    you might want to zoom out more or less according to your page size.

  13. Hemant says

    I’m facing same issue in Firefox 44.0.2. Our Python automation is not able to click on the “Give Away” button to test the giveaway page of goodreads.com. Please Help.

  14. Guna says

    Hey I am unable to click on button in firefox but if try to click manually it is working but with selenium it showing below error
    lement is not clickable at point (1100, 22). Other element would receive the click.
    i have tried y coordinates thing but it doesn’t work. Please help me on this.

  15. Deepak says

    Hey I am unable to click on button in firefox but if try to click manually it is working but with selenium it showing below error
    lement is not clickable at point (77, 590). Other element would receive the click.

    i have tried the x and y coordinates thing. Please help me on this.

  16. Łukasz says

    Everywhere it is written that this issue occurs only in Chrome. I use Firefox and I also had this problem. But your solution helped me. Thx a lot 🙂

  17. Rafael Carvalho says

    Hello,

    I was having problem running my UI tests inside a windows service application (Bamboo Server), and now after doing what you suggested everything is working good!

    Many thanks!!!

    (I am using Firefox driver)

  18. Janet Frank says

    I am also having this issue. I am using Java but when I add the JavaScriptExecutor to my code I do not get the method executeScript added. I am not sure what is happening here. As stated above my code us working fine for Firefox and Edge.

    • Mukesh Otwani says

      Hi Janet,

      Please make sure JavaScriptExecutor which you imported is coming from Selenium library or not?

      If not then please import the correct package and try again.

      Let me know if still facing the same issue then I will login and fix this.

  19. G Derilus says

    Hey with Selenium 2.48.2 release firefox is acting the save way can you update this article – This very useful article! thank you!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

AltStyle によって変換されたページ (->オリジナル) /