コード例 #1
0
        public void ExecuteJavaScript_callsWebdriverExecuteScript()
        {
            var mockSeleniumDriverFactory = new Mock <ISeleniumDriverFactory>();
            var mockWebDriver             = new Mock <IWebDriver>();
            var mockJsExecutor            = mockWebDriver.As <IJavaScriptExecutor>();

            mockSeleniumDriverFactory
            .Setup(s => s.Create(It.IsAny <BrowserType>(), It.IsAny <string>()))
            .Returns(mockWebDriver.Object);

            var seleniumBrowser = new SeleniumBrowser(mockSeleniumDriverFactory.Object,
                                                      new Mock <ISweetPotatoSettings>().Object, new Mock <ISeleniumElementFactory>().Object);

            seleniumBrowser.ExecuteJavaScript("foo javascript");

            mockJsExecutor.Verify(v => v.ExecuteScript("foo javascript"));
        }