0

I have a site we are testing, but for some reason the screen wraps and puts the 'search' buttons on the right, behind the fields. Like it is wrapping, and instead of being on the button below, it goes behind the field.

| improve this question | | | | |
  • This is the expected behavior of webdriver to throw ElementNotClickable exception when viewport of the element is wrapped by another element or obscured. – Kshetra Mohan Prusty Dec 11 '18 at 18:31
  • Yes. I know. Is there any way to work around it? Or change focus? Throw some Javascript in it? I see the issue with the vendor but I don't think they would rush to fix it for selenium tests. Trying to work around it. – Greg P Dec 11 '18 at 18:33
  • Could you please share the html content and a screenshot of the page highlighting the concerned element. A workaround could be find the co-ordinates of the location where the element is clickable, use Actions class to perform the click on the point. – Kshetra Mohan Prusty Dec 11 '18 at 18:38
  • I will look to see if I can find the coordinates and find a small corner to click on... – Greg P Dec 11 '18 at 18:52
0

Way is to use javascript to click on overlapping element is:

WebElement wb = driver.findElement(By.id("id of element"));
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].click();", wb);

Please let me know if that works for you. Webdriver provided the javscript implementation library so that we could use javascript to perform actions on browser which are not possible with with webdriver native API. And in web automation testing services we encountered many such issues where we have to go beyond webdriver native API and have to use javscript methods.

| improve this answer | | | | |
0

Move to element will try to click element in the center, if it doesn't work you can try to click it in the corner , see below sample to click right bottom

    public void ClickItInTheCorner(IWebElement element)
    {
        Actions action = new Actions(driver);
        action.MoveToElement(element, element.Size.Width, element.Size.Height).Click().Build().Perform();
    }
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.