Debugging “Element is not clickable at point” error

后端 未结 30 2109
余生分开走
余生分开走 2020-11-21 23:55

I see this only in Chrome.

The full error message reads:

\"org.openqa.selenium.WebDriverException: Element is not clickable at point (411, 675

相关标签:
30条回答
  • 2020-11-22 00:30

    Wow, a lot of answers here, and many good ones.

    I hope I'll add something to this from my experience.

    Well guys, in my case there was a cookie overlay hiding the element occasionally. Scrolling to the element also works; but in my humble opinion (for my case, not a panacea for everyone) the simplest solution is just to go full screen (I was running my scripts on a 3/4 of the screen window)! So here we go:

    driver.manage().window().maximize();
    

    Hope that helps!

    0 讨论(0)
  • 2020-11-22 00:30

    I was facing a similar problem whre i have to check two check boxes one after the other.But i was getting the same above error.hence i added wait in between my steps for checking the checkboxes....its working fine and great.here are the steps:-

      When I visit /administrator/user_profiles
      And I press xpath link "//*[@id='1']"
      Then I should see "Please wait for a moment..."
      When I wait for 5 seconds
      And I press xpath link "//*[@id='2']"
      Then I should see "Please wait for a moment..."
      When I visit /administrator/user_profiles_updates
    
    0 讨论(0)
  • 2020-11-22 00:32

    First, try to get the latest Chrome driver and check if it solves the issue.

    In my case, it didn't fix the issue. But, the following solution worked for me so far. The following is C# code but you can follow same logic in your specific language. What we do here is,

    Step 1: Focus on the element using the Selenium Actions object,

    Step 2: Then do a click on the element

    Step 3: If there's an exception, then we trigger a javascript "Click" event on the element by executing the javascript script through the Selenium browser driver's "ExecuteScript" method.

    You can also skip step 1 and 2 and try only step 3 too. Step 3 would work on it's own but I noticed some strange behavior in one scenario in which step 3, even though it successfully clicked the element, caused unexpected behavior in other parts of my code after clicking the element.

                try
                {
                    //Setup the driver and navigate to the web page...
                    var driver = new ChromeDriver("folder path to the Chrome driver");
                    driver.Navigate().GoToUrl("UrlToThePage");
    
                    //Find the element...
                    var element = driver.FindElement(By.Id("elementHtmlId")); 
    
                    //Step 1
                    new Actions(driver).MoveToElement(element).Perform();  
    
                    //Step 2
                    element.Click();
                }
                catch (Exception)
                {
                    //Step 3
                    driver.ExecuteScript("document.getElementById('elementHtmlId').click();");
    
                }
    
    0 讨论(0)
  • 2020-11-22 00:32

    I was getting this bug because I tested a hover and then needed to click on the link underneath the tooltip. The solution was to add page.find('.sp-logo').hover before click_link to get the tooltip out of the way.

    0 讨论(0)
  • 2020-11-22 00:32

    After testing all mentioned suggestions, nothing worked. I made this code. It works, but is not beautiful

    public void click(WebElement element) {
        //https://code.google.com/p/selenium/issues/detail?id=2766 (fix)
        while(true){
            try{
                element.click();
                break;
            }catch (Throwable e){
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    
    public void click(String css) {
        //https://code.google.com/p/selenium/issues/detail?id=2766 (fix)
        while(true){
            try{
                driver.findElement(By.cssSelector(css)).click();
                break;
            }catch (Throwable e){
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    
    0 讨论(0)
  • 2020-11-22 00:33

    I met this because a loading dialog cover on this element. I simplely solve it by add a waiting before working with the this element.

    try {
            Thread.sleep((int) (3000));
        } catch (InterruptedException e) {
            //
            e.printStackTrace();
        }
    

    Hope this help!

    0 讨论(0)
提交回复
热议问题