Exemple #1
0
        public void TestHighlightElementWhenDriverNotSupportedDoesNotThowException()
        {
            const string DefaultStyle = "color: blue;";

            var element = new Mock <IWebElement>(MockBehavior.Strict);

            element.Setup(e => e.GetAttribute("style")).Returns(DefaultStyle);

            var item      = element.Object;
            var webDriver = new Mock <IWebDriver>(MockBehavior.Strict);

            var nativePage = new NativePage();
            var page       = new SeleniumPage(nativePage, webDriver.Object);

            page.Highlight(item);

            element.VerifyAll();
            webDriver.VerifyAll();
        }
Exemple #2
0
        public void TestHighlightElementExecutesJavascript()
        {
            const string DefaultStyle = "color: blue;";
            const string JavaScript   = "arguments[0].setAttribute(arguments[1], arguments[2])";

            var element = new Mock <IWebElement>(MockBehavior.Strict);

            element.Setup(e => e.GetAttribute("style")).Returns(DefaultStyle);

            var item      = element.Object;
            var webDriver = new Mock <IWebDriver>(MockBehavior.Strict);

            webDriver.As <IJavaScriptExecutor>().Setup(j => j.ExecuteScript(JavaScript, item, "style", "border: 5px solid red;")).Returns((object)null);
            webDriver.As <IJavaScriptExecutor>().Setup(j => j.ExecuteScript(JavaScript, item, "style", DefaultStyle)).Returns((object)null);

            var nativePage = new NativePage();
            var page       = new SeleniumPage(nativePage, webDriver.Object);

            page.Highlight(item);

            element.VerifyAll();
            webDriver.VerifyAll();
        }