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


C# RemoteWebDriver.Navigate方法代码示例

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


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

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

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

示例3: MyTestInitialize

 public void MyTestInitialize()
 {
     verificationErrors = new StringBuilder();
     DesiredCapabilities capability = DesiredCapabilities.Firefox();
     driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);
     driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
     driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(50));
     driver.Manage().Window.Maximize();
     driver.Navigate();
 }
开发者ID:sergueik,项目名称:selenium_java,代码行数:10,代码来源:Test.cs

示例4: Run

        public void Run(string webProjectFolder, int portNumber)
        {
            var webApplication = new WebApplication(ProjectLocation.FromFolder(webProjectFolder), portNumber);
            _webServer = new IisExpressWebServer(webApplication);
            _webServer.Start();
            _webDriver = new FirefoxDriver();
            _webDriver.Navigate().GoToUrl(_webServer.BaseUrl);

            AppDomain.CurrentDomain.DomainUnload += CurrentDomainDomainUnload;
        }
开发者ID:ScotLowery2,项目名称:maintainable-automated-ui-tests,代码行数:10,代码来源:SeleniumRunner.cs

示例5: FindPrice

        public void FindPrice()
        {
            IWebDriver driver_ = new RemoteWebDriver(new Uri("http://192.168.1.4:4444/wd/hub"), DesiredCapabilities.Firefox());
            driver_.Navigate().GoToUrl("http://www.momoshop.com.tw");

            driver_.FindElement(By.CssSelector("#keyword")).SendKeys(this.SearchKeyWord_);
            driver_.FindElement(By.CssSelector(".inputbtn")).Click();

            Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>> info = new Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>>();

            try
            {
                if (driver_.FindElements(By.XPath("//*[@id=\"BodyBase\"]/form[1]/div/div[2]/div[5]/ul/li")).ToList().Count == 0)
                {
                    ReadProductDetail(driver_.Url, ref info);
                }
                else
                {
                    var PageCount = driver_.FindElements(By.XPath("//*[@id=\"BodyBase\"]/form[1]/div/div[2]/div[5]/ul/li")).ToList().Count;

                    for (var CurrentPage = 1; CurrentPage <= PageCount;)
                    {
                        List<IWebElement> products = driver_.FindElements(By.XPath("//*[@id=\"chessboard\"]/li/a")).ToList();
                        foreach (var product in products)
                        {
                            ReadProductDetail(product.GetAttribute("href"), ref info);
                        }

                        //Last Page
                        if (CurrentPage == PageCount)
                        {
                            break;
                        }

                        //Next Page
                        ++CurrentPage;
                        driver_.FindElement(By.XPath(string.Format("//*[@id=\"BodyBase\"]/form[1]/div/div[2]/div[5]/ul/li[{0}]/a", CurrentPage))).Click();
                    }

                }
            }
            catch (NoSuchElementException)
            {
            }

            this.ProductDetail_.Add("momo", info);
            driver_.Quit();
            if (LocalDriver_ != null)
            {
                LocalDriver_.Quit();
            }
            return;
        }
开发者ID:Shi-Yu-Chen,项目名称:FindPrice,代码行数:53,代码来源:SearchMomo.cs

示例6: SignInAsAdmin

        /// <summary>
        /// Log a user into the website as an administrator
        /// </summary>
        /// <param name="driver"></param>
        protected void SignInAsAdmin(RemoteWebDriver driver)
        {
            //Notice navigation is slightly different than the Java version
            //This is because 'get' is a keyword in C#
            driver.Navigate().GoToUrl(BaseUrl + "/User/SignIn");

            // Find the text input element by its name
            driver.FindElement(By.Name("Email")).SendKeys(_adminEmail);
            driver.FindElement(By.Name("Password")).SendKeys(_adminPass);
            driver.FindElement(By.CssSelector("button.btn-primary")).Click();
            driver.WaitFor(u => u.Url.Contains("Manage"));
        }
开发者ID:theriddlebrothers,项目名称:Honeypot,代码行数:16,代码来源:BaseTest.cs

示例7: Test2

        public void Test2()
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.SetCapability("device", "Android");
            capabilities.SetCapability("app", "Chrome");
            capabilities.SetCapability(CapabilityType.BrowserName, "Browser");
            capabilities.SetCapability(CapabilityType.Version, "4.3");
            capabilities.SetCapability(CapabilityType.Platform, "WINDOWS");
            IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
            driver.Navigate().GoToUrl("http://www.espn.com") ;

        }
开发者ID:tokarthik,项目名称:ProtoTest.Golem,代码行数:12,代码来源:AppiumTest.cs

示例8: GivenThatINavigateToABlogPostThatContainsAnImage

        public void GivenThatINavigateToABlogPostThatContainsAnImage()
        {
            var driver = new RemoteWebDriver(new Uri("http://localhost"), DesiredCapabilities.HtmlUnitWithJavaScript());

            // Find the text input element by its name
            driver.Navigate();

            // Enter something to search for
            IWebElement element = driver.FindElement(By.Id(""));

            // Now submit the form. WebDriver will find the form for us from the element
            //element.S
        }
开发者ID:kevinrjones,项目名称:mblog,代码行数:13,代码来源:MBlogMediaStepDefinitions.cs

示例9: CheckDriverThenClose

 private void CheckDriverThenClose(RemoteWebDriver driver)
 {
     try
     {
         Assert.IsNotNull(driver);
         driver.Navigate().GoToUrl("http://google.com");
         Log.Debug(GetUserAgent(driver));
     }
     finally
     {
         driver.Quit();
     }
 }
开发者ID:DevOpsDevine,项目名称:Radical-QA-Unshackler,代码行数:13,代码来源:WebDriverFactoryTest.cs

示例10: Should_be_able_to_read_text_from_label_when_content_is_more_than_just_text

        public void Should_be_able_to_read_text_from_label_when_content_is_more_than_just_text()
        {
            var pagePath = Path.Combine(Environment.CurrentDirectory, "markup.html");

            driver = new FirefoxDriver();
            driver.Navigate().GoToUrl(pagePath);

            var container = driver.FindElement(By.ClassName("some-class"));
            var labels = container.FindElements(By.TagName("label"));

            // This works:
            Assert.That(labels[0].GetAttribute("class"), Is.EqualTo("some-other-class"));

            // But not this:
            Assert.That(labels[0].Text, Is.EqualTo("Alla kommuner"));
        }
开发者ID:archive,项目名称:sandbox,代码行数:16,代码来源:ProblemWithLabelSpecs.cs

示例11: TitleIsCorrect

        public void TitleIsCorrect()
        {
            for (int i = 0; i < 30; i++)
            {
                //IWebDriver webDriver = new ChromeDriver();
                //IWebDriver webDriver = new PhantomJSDriver();
                // TODO ^^ So instead of this we do this:
                IWebDriver webDriver = new RemoteWebDriver(new Uri("http://localhost:4444"), new DesiredCapabilities());
                // ^^ this is how you'd call a Selenium Grid server, the desired capability is used to ask for a particular browser (or set of configuration)
                // you will need to first run phantomjs.exe --webdriver=4444
                // you might run a local instance simply by calling java -jar selenium-grid.jar or something, then register browsers with it
                // you could also call source labs, browserstack or whatever

                // When using ChromeDriver you could try reuisng a webdriver session,
                // but then you could get failing tests interfering with other tests, you can do some work to mitigation this and use things like cookejars to isolate tests
                // but with PhantomJS giving you a new session each time, you don't have to worry about it.

                // we had it so that failures would output a screenshot (that would get attached to the test result), this is available through the webdriver api and is support by PhantomJS
                // we also had the webdriver switchable by config, so that we could quickly switch to a full browser to troubleshoot bugs

                webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));


                webDriver.Navigate().GoToUrl("http://localhost:3988/");
                var header = webDriver.FindElement(By.CssSelector("div.jumbotron > h1"));
                header.Text.ShouldBe("ASP.NET");
            }

            //var liCount = _webDriver.FindElement(By.Id("test-content")).FindElements(By.TagName("li")).Count;

            //liCount.ShouldBe(3);

            // This sort of fiddly stuff, i.e. elements with timeouts, domReady etc... are not as bad as I remember.
            // because FindElements will wait using the _webdriver implicit wait settings (set when we construct the WebDriver object)
            // but what if there was already an <li> in the list, it fails! what if the dom exists, but then we replace it with ajax

            // thats when you might do something explicit like this:

            //var fiveSecondWait = new WebDriverWait(_webDriver, TimeSpan.FromSeconds(5));
            //fiveSecondWait.Until(wd =>
            //{
            //    // do some checks
            //    return true;
            //});

            // We used to queue some javascript so that we know that all synchrounous task had been parse and completed by the browser and we were ready to rock
        }
开发者ID:slang25,项目名称:SampleAutomatedWebTesting,代码行数:47,代码来源:Tests.cs

示例12: SpecifyForBrowser

        public override void SpecifyForBrowser(RemoteWebDriver driver)
        {
            given("a non null driver", delegate()
            {
                Assert.IsNotNull(driver);
                when("we goto google.com", delegate()
                {
                    driver.Navigate().GoToUrl("http://google.com");
                    then("we can get the user agent",
                        delegate()
                            {
                                expect(() => GetUserAgent(driver).Length >0);
                            });
                });

            });
        }
开发者ID:DevOpsDevine,项目名称:Radical-QA-Unshackler,代码行数:17,代码来源:GoogleTests.cs

示例13: OpenHtmlUnitDriver

 public static void OpenHtmlUnitDriver()
 {
     // initialize a WebDriver instance
     //IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.HtmlUnit());
     IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.HtmlUnit());
     // load google search page
     driver.Navigate().GoToUrl("https://www.google.ca");
     // print title
     Console.WriteLine("Page title: " + driver.Title);
     // enter search word and submit
     IWebElement element = driver.FindElement(By.Name("q"));
     element.SendKeys("Cheese");
     element.Submit();
     // print title
     Console.WriteLine("Page title: " + driver.Title);
     // quit the driver
     driver.Quit();
 }
开发者ID:andyfengc,项目名称:SeleniumTutorialNet,代码行数:18,代码来源:BrowserDemo.cs

示例14: _Setup

        /// <summary>starts a sauce labs sessions</summary>
        /// <param name="browser">name of the browser to request</param>
        /// <param name="version">version of the browser to request</param>
        /// <param name="platform">operating system to request</param>
        private IWebDriver _Setup(string browser, string version, string platform)
        {
            // construct the url to sauce labs
            Uri commandExecutorUri = new Uri("<http://ondemand.saucelabs.com/wd/hub>");
            // set up the desired capabilities
            DesiredCapabilities desiredCapabilites = new DesiredCapabilities(browser, version, Platform.CurrentPlatform); // set the desired browser
            desiredCapabilites.SetCapability("platform", platform); // operating system to use
            desiredCapabilites.SetCapability("username", Constants.SAUCE_LABS_ACCOUNT_NAME); // supply sauce labs username
            desiredCapabilites.SetCapability("accessKey", Constants.SAUCE_LABS_ACCOUNT_KEY);  // supply sauce labs account key
            desiredCapabilites.SetCapability("name", TestContext.CurrentContext.Test.Name); // give the test a name

            // start a new remote web driver session on sauce labs
            var _Driver = new RemoteWebDriver(commandExecutorUri, desiredCapabilites);
            _Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));

            // navigate to the page under test
            _Driver.Navigate().GoToUrl("<https://saucelabs.com/test/guinea-pig>");

            return _Driver;
        }
开发者ID:saucelabs-sample-scripts,项目名称:C-Sharp-Selenium,代码行数:24,代码来源:GuineaPigTests.cs

示例15: Main

        static void Main(string[] args)
        {
            Local local = new Local();

              List<KeyValuePair<string, string>> options = new List<KeyValuePair<string, string>>() {
            new KeyValuePair<string, string>("key", BROWSERSTACK_ACCESS_KEY),
            //new KeyValuePair<string, string>("localIdentifier", "identifier"),
            //new KeyValuePair<string, string>("f", "C:\\Users\\Admin\\Desktop\\"),
            new KeyValuePair<string, string>("onlyAutomate", "true"),
            new KeyValuePair<string, string>("verbose", "true"),
            new KeyValuePair<string, string>("forcelocal", "true"),
            new KeyValuePair<string, string>("binarypath", "C:\\Users\\Admin\\Desktop\\BrowserStackLocal.exe"),
            new KeyValuePair<string, string>("logfile", "C:\\Users\\Admin\\Desktop\\local.log"),
              };
              local.start(options);

              // Run WebDriver Tests
              IWebDriver driver;
              DesiredCapabilities capability = DesiredCapabilities.Firefox();
              capability.SetCapability("browserstack.user", BROWSERSTACK_USERNAME);
              capability.SetCapability("browserstack.key", BROWSERSTACK_ACCESS_KEY);
              //capability.SetCapability("browserstack.localIdentifier", "identifier");
              capability.SetCapability("browserstack.local", true);
              capability.SetCapability("build", "build");

              driver = new RemoteWebDriver(
            new Uri("http://hub.browserstack.com/wd/hub/"), capability
              );
              driver.Navigate().GoToUrl("http://www.google.com");
              Console.WriteLine(driver.Title);

              IWebElement query = driver.FindElement(By.Name("q"));
              query.SendKeys("Browserstack");
              query.Submit();
              Console.WriteLine(driver.Title);

              driver.Quit();
              local.stop();
              Console.WriteLine("Test Completed.");
              Console.ReadLine();
        }
开发者ID:browserstack,项目名称:browserstack-local-csharp,代码行数:41,代码来源:Example.cs


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