Selenium - Element is not clickable at point

后端 未结 7 1306
无人共我
无人共我 2020-12-30 06:30

I am using selenium for test script. I am getting following error and this error randomly occur. When I run 10 times, I get this about twice. So it\'s not really reproducibl

相关标签:
7条回答
  • 2020-12-30 07:02
    • This happens only on chrome so it works on ie and firefox
    • ChromeDriver always clicks the middle of the element
    • The reason Chrome driver doesn't calculate the correct screen location of link.

    Solution:

    // Find an element and define it
    
    WebElement elementToClick = driver.findElement(By.xpath("some xpath"));
    // Scroll the browser to the element's Y position
    ((JavascriptExecutor) driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().y+")");
    // Click the element
    elementToClick.click();
    
    0 讨论(0)
提交回复
热议问题