當前位置: 首頁>>代碼示例>>C#>>正文


C# RemoteWebDriver.ExecuteScript方法代碼示例

本文整理匯總了C#中OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScript方法的典型用法代碼示例。如果您正苦於以下問題:C# RemoteWebDriver.ExecuteScript方法的具體用法?C# RemoteWebDriver.ExecuteScript怎麽用?C# RemoteWebDriver.ExecuteScript使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenQA.Selenium.Remote.RemoteWebDriver的用法示例。


在下文中一共展示了RemoteWebDriver.ExecuteScript方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WaitUnitJavascriptTrue

 private static void WaitUnitJavascriptTrue(RemoteWebDriver driver, string javascript)
 {
     Func<IWebDriver, bool> condition = delegate
                                            {
                                                var scriptResult = driver.ExecuteScript(javascript);
                                                var isScriptActive = (bool)scriptResult;
                                                return isScriptActive;
                                            };
     driver.Wait().Until(condition);
 }
開發者ID:muruaaaa9,項目名稱:Automated-Test,代碼行數:10,代碼來源:RemoteWebDriverExtensions.cs

示例2: SmokeTestSetup

        public void SmokeTestSetup()
        {
            driver = new FirefoxDriver();

            _runner = new NzbDroneRunner(LogManager.GetCurrentClassLogger());
            _runner.KillAll();
            _runner.Start();

            driver.Url = "http://localhost:8989";

            var page = new PageBase(driver);
            page.WaitForNoSpinner();

            driver.ExecuteScript("window.NzbDrone.NameViews = true;");

            GetPageErrors().Should().BeEmpty();
        }
開發者ID:Djohnnie,項目名稱:Sonarr,代碼行數:17,代碼來源:AutomationTest.cs

示例3: Connect

 public bool Connect()
 {
     try
     {
         Dictionary<string, object> capsDef = new Dictionary<string, object>();
         capsDef.Add("device", _Model.Settings.InspectorDeviceCapability.ToString());
         ICapabilities capabilities = new DesiredCapabilities(capsDef);
         _Driver = new ScreenshotRemoteWebDriver(new Uri("http://" + this._Model.IPAddress + ":" + this._Model.Port.ToString() + "/wd/hub"), capabilities);
         // add increased timeout for inspector connection
         Dictionary<string, int> args = new Dictionary<string, int>();
         args.Add("timeout", 900);
         _Driver.ExecuteScript("mobile: setCommandTimeout", new object[] { args });
     }
     catch (Exception e)
     {
         LastMessage = e.Message;
         return false;
     }
     return true;
 }
開發者ID:Thwaitesy,項目名稱:appium-dot-exe,代碼行數:20,代碼來源:InpsectorForm.cs

示例4: GetUserAgent

 private string GetUserAgent(RemoteWebDriver driver)
 {
     return driver.ExecuteScript("return window.navigator.userAgent;").ToString();
 }
開發者ID:DevOpsDevine,項目名稱:Radical-QA-Unshackler,代碼行數:4,代碼來源:WebDriverFactoryTest.cs

示例5: ReportCapabilities

 private static void ReportCapabilities(RemoteWebDriver driver)
 {
     Log.InfoFormat("Driver Capabilities: {0}", driver.Capabilities);
     Log.InfoFormat("User agent: {0}", driver.ExecuteScript("return navigator.userAgent;"));
 }
開發者ID:DevOpsDevine,項目名稱:Radical-QA-Unshackler,代碼行數:5,代碼來源:WebDriverFactory.cs

示例6: SaveHtmlAndScreenShot

 private static void SaveHtmlAndScreenShot(Uri uri, RemoteWebDriver _driver)
 {
     try
     {
         var removeScriptTag =
             "Array.prototype.slice.call(document.getElementsByTagName('script')).forEach(function(item) { item.parentNode.removeChild(item);});";
         var addClassToBody = "document.getElementsByTagName('body')[0].className += ' seoPrerender';";
         
         _driver.ExecuteScript(removeScriptTag + addClassToBody);   
         //uri.AbsolutePath is relative url
         var result = _driver.PageSource;
         string filenameWithPath = _options.FolderPath + uri.AbsolutePath + MakeValidFileName(uri.Query);
         Directory.CreateDirectory(Path.GetDirectoryName(filenameWithPath));
         File.WriteAllText(filenameWithPath + ".html", result);
         logger.Info("SaveHtmlAndScreenShot to {0}.html", filenameWithPath);
         _driver.GetScreenshot().SaveAsFile(filenameWithPath + ".jpg", ImageFormat.Jpeg);
     }
     catch (Exception ex)
     {
         logger.Error(ex);
     }
 }
開發者ID:Asing1001,項目名稱:Seo.Crawler.Service,代碼行數:22,代碼來源:Crawler.cs

示例7: SetDateValueForJQueryDatepicker

 public static void SetDateValueForJQueryDatepicker(RemoteWebDriver browser, string elementSelector, DateTime value)
 {
     var formattedDate = value.ToString("d MMMM yyyy");
     browser.FindElementByCssSelector(elementSelector);
     browser.ExecuteScript("$(arguments[0]).datepicker('setDate', arguments[1]);", elementSelector, formattedDate);
 }
開發者ID:Natsui31,項目名稱:keyhub,代碼行數:6,代碼來源:SiteUtil.cs

示例8: BlockUntilElementIsAvailable

 private void BlockUntilElementIsAvailable(RemoteWebDriver driver, string elementSelector)
 {
     while (true)
     {
         var len = driver.ExecuteScript("return $(\"" + elementSelector + "\").length");
         if (Convert.ToInt32(len) > 0)
             break;
         Thread.Sleep(100);
     }
 }
開發者ID:etcoding,項目名稱:JasmineAsNUnit,代碼行數:10,代碼來源:GoogleTests.cs


注:本文中的OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScript方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。