当前位置: 首页>>代码示例>>C#>>正文


C# Remote.RemoteWebDriver类代码示例

本文整理汇总了C#中OpenQA.Selenium.Remote.RemoteWebDriver的典型用法代码示例。如果您正苦于以下问题:C# RemoteWebDriver类的具体用法?C# RemoteWebDriver怎么用?C# RemoteWebDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RemoteWebDriver类属于OpenQA.Selenium.Remote命名空间,在下文中一共展示了RemoteWebDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LaunchBrowser

        /// <summary>
        /// Launches the Selenium WebDriver driven browser specified in the Environments.cs file
        /// </summary>
        public IWebDriver LaunchBrowser(IWebDriver driver)
        {
            switch(this.environment.browser)
            {
                case "*firefox":
                    _ffp = new FirefoxProfile();
                    _ffp.AcceptUntrustedCertificates = true;
                    driver = new FirefoxDriver(_ffp);
                    break;
                case "*iexplore":
                    driver = new InternetExplorerDriver();
                    break;
                case "*googlechrome":
                    driver = new ChromeDriver();
                    break;
                case "Android":
                    capabilities = new DesiredCapabilities("android", "", null);
                    capabilities.IsJavaScriptEnabled = true;
                    driver = new RemoteWebDriver(new Uri(string.Format("http://{0}:{1}/hub", environment.host, environment.port)), capabilities);
                    break;
                case "RemoteWebDriver":
                    capabilities = DesiredCapabilities.Firefox();
                    var remoteAddress = new Uri(string.Format("http://{0}:{1}/wd/hub", environment.host, environment.port));
                    driver = new RemoteWebDriver(remoteAddress, capabilities);
                    break;
            }

            return driver;
        }
开发者ID:tmacblane,项目名称:TestManager,代码行数:32,代码来源:WebBrowser.cs

示例2: ShouldBeAbleToCreateRemoteWebDriverWithNoSlashAtEndOfUri

 public void ShouldBeAbleToCreateRemoteWebDriverWithNoSlashAtEndOfUri()
 {
     Environment.EnvironmentManager.Instance.CloseCurrentDriver();
     RemoteWebDriver noSlashDriver = new RemoteWebDriver(new Uri("http://127.0.0.1:6000/wd/hub"), DesiredCapabilities.InternetExplorer());
     noSlashDriver.Url = javascriptPage;
     noSlashDriver.Quit();
 }
开发者ID:draculavlad,项目名称:selenium,代码行数:7,代码来源:RemoteWebDriverSpecificTests.cs

示例3: RunTest

        protected void RunTest(String browserType, String url)
        {
            APP_LOGGER.Debug("Running Test With " + browserType + " on URL " + url);

            // Open Browser
            IWebDriver wd ;

            if (browserType.Equals("firefox"))
                wd = new RemoteWebDriver(new Uri(ResourceTestFilePaths.GridHubURL), DesiredCapabilities.Firefox());
            else if (browserType.Equals("safari"))
                wd = new RemoteWebDriver(new Uri(ResourceTestFilePaths.GridHubURL), DesiredCapabilities.Safari());
            else if(browserType.Equals("chrome"))
                wd = new RemoteWebDriver(new Uri(ResourceTestFilePaths.GridHubURL), DesiredCapabilities.Chrome());
            else
                wd = new RemoteWebDriver(new Uri(ResourceTestFilePaths.GridHubURL), DesiredCapabilities.InternetExplorer());

            // Go to Google.com
            wd.Url = url;

            Random rnd = new Random();
            int randomSeconds = rnd.Next(1, 11);

            // Wait for Random Time (1s to 10 s)
            APP_LOGGER.DebugFormat("Waiting for {0} seconds Before Exiting Browser", randomSeconds);
            Thread.Sleep(TimeSpan.FromSeconds(randomSeconds));

            // Quit Browser
            wd.Quit();
        }
开发者ID:sandeepsajiru,项目名称:DDF,代码行数:29,代码来源:TestCaseBase.cs

示例4: Create

    public static IWebDriver Create(string browser)
    {
        DesiredCapabilities capabilities;
        IWebDriver driver;

        switch (browser) {
            case "chrome":
                capabilities = DesiredCapabilities.Chrome();
                driver = new RemoteWebDriver(remoteWebDriverUri, capabilities);
                break;
            case "internet explorer":
                InternetExplorerOptions options = new InternetExplorerOptions();
                options.IgnoreZoomLevel = true;
                capabilities = (DesiredCapabilities)options.ToCapabilities();
                driver = new RemoteWebDriver(remoteWebDriverUri, capabilities, TimeSpan.FromSeconds(10));
                break;
            case "edge":
                capabilities = DesiredCapabilities.Edge();
                driver = new RemoteWebDriver(remoteWebDriverUri, capabilities);
                break;
            default:
                capabilities = DesiredCapabilities.Firefox();
                driver = new RemoteWebDriver(remoteWebDriverUri, capabilities);
                break;
        }

        return driver;
    }
开发者ID:chrhol,项目名称:Launcher,代码行数:28,代码来源:WebDriverFactory.cs

示例5: getWebDriver

        public static RemoteWebDriver getWebDriver(string DriverName = "")
        {
            if (WebDriver == null)
            {
                switch (DriverName)
                {
                    case "IE":
                        var options = new InternetExplorerOptions();
                        options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                        WebDriver = new InternetExplorerDriver(/*Settings.CurrentSettings.BrowserPath,*/ options);

                        //IeCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
                //WebDriver = new InternetExplorerDriver(ieCapabilities);
                        break;
                    case "CHROME":
                    default:
                        WebDriver = new ChromeDriver();
                        break;
                }
                /*System.setProperty("webdriver.ie.driver", "src\\test\\resources\\drivers\\IEDriverServer.exe");
                DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
                ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
                webDriver = new InternetExplorerDriver(ieCapabilities);
                webDriver.manage().timeouts()
                        .implicitlyWait(WAIT_TIMEOUT, TimeUnit.MILLISECONDS);
                maximizeBrowser();*/
                WebDriver.Manage().Timeouts()
                        .ImplicitlyWait(TimeSpan.FromSeconds(WAIT_TIMEOUT));
                MaximizeBrowser();
            }

            return WebDriver;
        }
开发者ID:VNikita,项目名称:Test_auto,代码行数:33,代码来源:WebDriverSetup.cs

示例6: FillVendorCredentialForm

 private static void FillVendorCredentialForm(RemoteWebDriver browser, string name, string value)
 {
     browser.FindElementByCssSelector("input#CredentialName").Clear();
     browser.FindElementByCssSelector("input#CredentialName").SendKeys(name);
     browser.FindElementByCssSelector("input#CredentialValue").Clear();
     browser.FindElementByCssSelector("input#CredentialValue").SendKeys(value);
 }
开发者ID:Natsui31,项目名称:keyhub,代码行数:7,代码来源:AdminTests.cs

示例7: ClickPrimary

 public static void ClickPrimary(RemoteWebDriver driver)
 {
     // Unable to click the Okay button due to chrome driver issue.
     // @see http://code.google.com/p/selenium/issues/detail?id=2766
     // Just run direct JS
     (driver as IJavaScriptExecutor).ExecuteScript("$('.modal-footer .btn-primary').trigger('click')");
 }
开发者ID:theriddlebrothers,项目名称:Honeypot,代码行数:7,代码来源:ModalHelper.cs

示例8: setup

        //private static ISelenium selenium;

        
        
        public static void setup()
        {
            
            IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),DesiredCapabilities.HtmlUnit());
                        
            //driver = new FirefoxDriver();
            Selenium.WebDriverBackedSelenium s = new Selenium.WebDriverBackedSelenium(driver, @"http://site4.way2sms.com/content/index.html");
            s.Start();
            driver.Navigate().GoToUrl("http://site4.way2sms.com/content/index.html");
            
            
            WaitForLinkTextPresent(driver, "► click here to go to way2sms.com", 40);
            driver.FindElement(By.Id("username")).SendKeys("9916089888");
            driver.FindElement(By.Id("password")).SendKeys("suprwolf");
            driver.FindElement(By.Id("button")).Click();
            

            if (WaitIdPresent(driver, "quickclose1",40000))
            {
                driver.FindElement(By.Id("quickclose1")).Click();
            }

            driver.FindElement(By.Id("quicksms")).Click();
            driver.SwitchTo().Frame("frame");
            s.WaitForPageToLoad("30000");
            driver.FindElement(By.Id("MobNo")).SendKeys("9916089888");
            WaitIdPresent(driver, "textArea", 400);
            driver.FindElement(By.Id("textArea")).SendKeys("test");

            driver.FindElement(By.Id("Send")).Submit();
            driver.FindElement(By.LinkText("Logout")).Clear();
           
            
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:38,代码来源:Class1.cs

示例9: Authenticate

		public static IWebDriver Authenticate()
		{
			string email = "[email protected]";
			IWebDriver webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome());
			//webDriver.Manage().Window.Maximize();
			webDriver.Navigate().GoToUrl("http://dev.icms/Account/Login");
			//Enter email address on login page
			IWebElement emailLogin = webDriver.FindElement(By.Id("Email"));
			emailLogin.Clear();
			emailLogin.SendKeys(email);
			IWebElement authenticateButton = webDriver.FindElement(By.Id("requestauth"));
			authenticateButton.Click();
			//this should have sent me an email
			//Let's pretend we got the email and check the server for the authtoken and plug it into the URL

			string token = HttpUtility.UrlEncode(TestUtilities.AuthenticationUtil.GetAuthToken(email));
			string goToUrl = string.Format("http://dev.icms/account/authorize/?authtoken={0}&email={1}&returnUrl=%2f", token, email);

			webDriver.Quit();
			webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome());

			webDriver.Navigate().GoToUrl(goToUrl);

			//Check DOM to see if we are logged in
			IWebElement elem = webDriver.FindElement(By.CssSelector("h1"));
			//webDriver.Quit();
			if (elem.Text == "Welcome Admin Development")
			{
				return webDriver;
			}
			return null;
		}
开发者ID:MarneeDear,项目名称:Terminal-Management-Apps-Tests,代码行数:32,代码来源:BaseTest.cs

示例10: GetRemoteWebDriver

        private static IWebDriver GetRemoteWebDriver()
        {
            IWebDriver driver = new RemoteWebDriver(new Uri(Configuration.Instance.Selenium.RemoteGridHub),
                DesiredCapabilities.Chrome());


            return driver;
        }
开发者ID:backand,项目名称:SeleniumAutomation,代码行数:8,代码来源:DriversPool.cs

示例11: SubmitLoginForm

 public static void SubmitLoginForm(RemoteWebDriver browser, string email, string password)
 {
     var formSelector = "form[action^='/Account/Login'] ";
     browser.FindElementByCssSelector(formSelector + "input#Email").SendKeys(email);
     browser.FindElementByCssSelector(formSelector + "input#Password").SendKeys(password);
     browser.FindElementByCssSelector(formSelector + "input[value='Log in']").Click();
     WaitUntilUserIsLoggedIn(browser);
 }
开发者ID:Natsui31,项目名称:keyhub,代码行数:8,代码来源:SiteUtil.cs

示例12: CloseBrowser

 public static void CloseBrowser(RemoteWebDriver browser)
 {
     if (browser != null)
     {
         browser.Close();
         browser.Dispose();
         browser = null;
     }
 }
开发者ID:ehelin,项目名称:TgimbaSeleniumTests,代码行数:9,代码来源:Utilities.cs

示例13: GetFirefoxServerDriver

        public static RemoteWebDriver GetFirefoxServerDriver()
        {
            DesiredCapabilities capability = DesiredCapabilities.Firefox();

            RemoteWebDriver driver = new RemoteWebDriver(
                new Uri(String.Format("http://{0}/wd/hub", Settings.Default.hostnameServer)),
                capability);
            return driver;
        }
开发者ID:BobLokerse,项目名称:SeleniumCoding,代码行数:9,代码来源:Browser.cs

示例14: 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

示例15: MyTestInitialize

      public void MyTestInitialize()
      {
         browser = this.TestContext.Properties["browser"] != null ? this.TestContext.Properties["browser"].ToString() : "ie";

         switch (browser)
         {
            case "firefox":
               driver = new FirefoxDriver();
               break;

            case "chrome":
               driver = new ChromeDriver();
               break;

            default:
               driver = new InternetExplorerDriver();
               break;
         }

         // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
         if (this.TestContext.Properties["webAppUrl"] != null)
         {
            this.baseURL = this.TestContext.Properties["webAppUrl"].ToString();
         }
         else
         {
            this.baseURL = "http://peopletrackerdockerhost-dev.westus.cloudapp.azure.com/";
         }
      }
开发者ID:squillace,项目名称:PeopleTracker.us,代码行数:29,代码来源:PeopleCRUDTests.cs


注:本文中的OpenQA.Selenium.Remote.RemoteWebDriver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。