Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97773

How to check the element is available in viewport after selecting an element and page refresh using selenium (with in the desktop screen)

$
0
0

Issue: After selecting an element, refreshing the page, the element is not visible. And after fix, the element is visible without doing any scroll after page refresh. So that I can select a different option.

I tried below and irrespective of element present in viewport (with in visible screen) or not test is passing. I really appreciate if someone could post solution.

WebElement element =
> WebDriverManager.getWebDriver().findElement(By.id("CUSTRATINGS"));
> 
>         WebDriver driver = ((RemoteWebElement)element).getWrappedDriver();
> 
>         return (Boolean)((JavascriptExecutor)driver).executeScript(
>                 "var elem = arguments[0],                 " +
>                         "  box = elem.getBoundingClientRect(),    " +
>                         "  cx = box.left + box.width / 2,         " +
>                         "  cy = box.top + box.height / 2,         " +
>                         "  e = document.elementFromPoint(cx, cy); " +
>                         "for (; e; e = e.parentElement) {         " +
>                         "  if (e === elem)                        " +
>                         "    return true;                         " +
>                         "}                                        " +
>                         "return false;                            ">                 , element);

Viewing all articles
Browse latest Browse all 97773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>