当前位置: 首页>>代码示例>>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;未经允许,请勿转载。