示例#1
0
        protected void MoveElementToMiddleOfPage(IWebElement element)
        {
            //scroll element to middle of the page
            string script = "var viewPortHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);" +
                            "var elementTop = arguments[0].getBoundingClientRect().top;" +
                            "window.scrollBy(0, elementTop-(viewPortHeight/2));";

            WebDriverHelper.ExecuteJavascript(script, element);
        }
示例#2
0
 private void WaitUntilDocumentHasFullyLoaded()
 {
     try
     {
         //Selenium webdriver executes to quickly at times, this method will ensure that
         //the page has always been fully loaded before each action
         WaitUntil(wd => WebDriverHelper.ExecuteJavascript("return document.readyState").ToString() == "complete");
     }
     catch
     {
         //Swallow exception - ignore exceptions thrown by Javascript
     }
 }
示例#3
0
 public void ScrollDown()
 {
     WebDriverHelper.ExecuteJavascript("window.scrollTo(0, document.body.scrollHeight - 150)");
 }