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


C# FirefoxDriver.FindElementByName方法代码示例

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


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

示例1: testBasketballPage

        /// <summary>
        /// Test form submission on Krossover basketball page
        /// </summary>
        public void testBasketballPage(FirefoxDriver driver)
        {
            //variables to enter in form
            string page = "http://www.krossover.com/basketball/";
            string name = "Jóhn Dóe"; //international character testing
            string teamName = "Test Team";
            string city = "New York";
            string state = "NY";
            string sport = "Football";
            string gender = "Male";
            string email = "[email protected]";
            string phone = "123-456-789";
            string day = "Friday";

            //fill out all the fields
            driver.Navigate().GoToUrl(page);
            driver.FindElementByName("Field1").SendKeys(name);
            driver.FindElementByName("Field2").SendKeys(teamName);
            driver.FindElementByName("Field3").SendKeys(city);
            driver.FindElementByName("Field4").SendKeys(state);
            driver.FindElementByName("Field6").FindElement(By.XPath(".//option[contains(text(),'" + sport + "')]")).Click();
            driver.FindElementByName("Field7").FindElement(By.XPath(".//option[contains(text(),'" + gender + "')]")).Click();
            driver.FindElementByName("Field9").SendKeys(email);
            driver.FindElementByName("Field11").SendKeys(phone);
            driver.FindElementByName("Field14").FindElement(By.XPath(".//option[contains(text(),'" + day + "')]")).Click();

            driver.FindElementByName("saveForm").Click(); //submit the form

            /*verify the form submission was actually generated by querying the db
             * if so, test passes
             * else, test fails
            */
            driver.Quit();
        }
开发者ID:dhruv0018,项目名称:Krossover,代码行数:37,代码来源:TestBasketballPage.cs

示例2: Visibility_NewTwitter

        public void Visibility_NewTwitter()
        {
            var browser = new FirefoxDriver();
            browser.Navigate().GoToUrl("http://www.twitter.com");

            browser.FindElementByName("session[username_or_email]").SendKeys("theuser");
            browser.FindElementByName("session[password]").SendKeys("thepass");
        }
开发者ID:AndrewVos,项目名称:Coypu,代码行数:8,代码来源:RawWebdriver.cs

示例3: Ensure_Dashboard_Loads_And_Can_Logon

 public void Ensure_Dashboard_Loads_And_Can_Logon()
 {
     var dashboardUrl = ConfigurationManager.AppSettings["Pwinty-Dashboard-Url"];
     using(var firefoxDriver = new FirefoxDriver())
     {
         firefoxDriver.Url = dashboardUrl;
         var emailField = firefoxDriver.FindElementByName("Email");
         var passwordField = firefoxDriver.FindElementByName("Password");
     }
 }
开发者ID:tomgallard,项目名称:pwinty-dotnet,代码行数:10,代码来源:EnvironmentSmokeTest.cs

示例4: FindingStuff_CarBuzz

        public void FindingStuff_CarBuzz()
        {
            var browser = new FirefoxDriver();
            browser.Navigate().GoToUrl("http://carbuzz.heroku.com/car_search");

            browser.FindElementByName("make_17").Click();
            browser.FindElementByName("make_14").Click();
            browser.FindElementByName("make_11").Click();

            Assert.That(browser.PageSource.Contains(" 5 car reviews found"));

            browser.FindElementByXPath("//ul[@class='seats']/li/button[@value='4']").Click();

            Assert.That(browser.PageSource.Contains(" 1 car reviews found"));
        }
开发者ID:AndrewVos,项目名称:Coypu,代码行数:15,代码来源:RawWebdriver.cs

示例5: Retries_Autotrader

        public void Retries_Autotrader()
        {
            var browser = new FirefoxDriver();
            browser.Navigate().GoToUrl("http://www.autotrader.co.uk/used-cars");

            browser.FindElementByName("postcode").SendKeys("N1 1AA");

            browser.FindElementByName("make").FindElements(By.TagName("option")).First(e => e.GetAttribute("value") == "citroen").Select();
            browser.FindElementByName("model").FindElements(By.TagName("option")).First(e => e.GetAttribute("value") == "c4_grand_picasso").Select();
            browser.FindElementByName("radius").FindElements(By.TagName("option")).First(e => e.Text == "National").Select();
            browser.FindElementByName("fuel-type").FindElements(By.TagName("option")).First(e => e.GetAttribute("value") == "diesel").Select();
            browser.FindElementByName("maximum-age").FindElements(By.TagName("option")).First(e => e.GetAttribute("value") == "up_to_7_years_old").Select();
            browser.FindElementByName("maximum-mileage").FindElements(By.TagName("option")).First(e => e.GetAttribute("value") == "up_to_60000_miles").Select();

            browser.FindElementByName("keywords").SendKeys("vtr");
        }
开发者ID:AndrewVos,项目名称:Coypu,代码行数:16,代码来源:RawWebdriver.cs

示例6: Search

        public void Search()
        {
            var driver = new FirefoxDriver();
            driver.Url = "http://www.google.com";

            var textbox = driver.FindElementByName("q");
            textbox.SendKeys("cats");
            textbox.Submit();

            // Google's search is rendered dynamically with JavaScript.
            // Wait for the page to load, timeout after 10 seconds
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            wait.Until(x => x.Title.ToLower().StartsWith("cats"));

            Assert.IsTrue(driver.Title.Contains("cats"));
            driver.Quit();
        }
开发者ID:snahider,项目名称:Test-Automation-NET,代码行数:17,代码来源:GoogleSearchTests.cs

示例7: EnterDummyPaymentOptions

        private void EnterDummyPaymentOptions(FirefoxDriver seleniumInstance,StripeCardDetails cardDetails)
        {
            seleniumInstance.SwitchTo().Frame(seleniumInstance.FindElementByCssSelector(".stripe_checkout_app"));
            var emailEl = seleniumInstance.FindElementByName("email");
            emailEl.SendKeys("[email protected]");
            var cardEl = seleniumInstance.FindElementByName("card_number");
            cardEl.SendKeys(cardDetails.CardNumber);
            var expiresEl = seleniumInstance.FindElementByName("cc-exp");
            expiresEl.SendKeys(cardDetails.Expiry);
            //var nameOnCard = seleniumInstance.FindElementById("paymentName");
            //nameOnCard.SendKeys(cardDetails.CardHolderName);
            var cvc = seleniumInstance.FindElementByName("cc-csc");
            cvc.SendKeys(cardDetails.CVC);

            var submitButton = seleniumInstance.FindElementByCssSelector(".button button");
            submitButton.ClickWithJavascript(seleniumInstance);
        }
开发者ID:tomgallard,项目名称:pwinty-dotnet,代码行数:17,代码来源:PaymentTest.cs

示例8: Main

        static void Main(string[] args)
        {
            RemoteWebDriver browser = new FirefoxDriver();

            try
            {
                browser.Navigate().GoToUrl("http://alitrack.ru/");

                #region Login
                if (browser.FindElementByName("login") != null)
                {
                    browser.FindElementByName("login").SendKeys(cabinet.alitrack.ru.Properties.Settings.Default.UserName);
                    browser.FindElementByName("pass").SendKeys(cabinet.alitrack.ru.Properties.Settings.Default.Password);
                    browser.FindElementByXPath("//input[@type='submit']").Click();
                }
                #endregion

                WaitForCompleteXPath(browser, "//a[contains(@href,'tracking')]");
                browser.Navigate().GoToUrl("http://cabinet.alitrack.ru/tracking/");
                WaitForCompleteXPath(browser, "//a[contains(@href,'tracking')]");


                if (browser.PageSource.Contains("trackingCheckAllItems"))
                {
                    #region update
                    browser.FindElementById("trackingCheckAllItems").Click();
                    var alert = browser.SwitchTo().Alert();
                    alert.Accept();
                    WaitForCompleteXPath(browser, "//div[@id='processingWindow' and contains(@style,'display: none;')]");
                    var trackingRows = browser.FindElementsByClassName("tracking-row");

                    foreach (var trackingRow in trackingRows)
                    {
                        Console.WriteLine(trackingRow.FindElement(By.ClassName("name")).Text);
                        string number = trackingRow.GetAttribute("id").Replace("trow", string.Empty);
                        if (browser.PageSource.Contains(string.Format("id=\"refresh-button{0}\"", number)))
                        {
                            browser.FindElementById("refresh-button" + number).Click();
                            WaitForCompleteXPath(browser, "//div[@id='processingWindow' and contains(@style,'display: none;')]");
                        }
                    }
                    #endregion

                    #region find new
                    browser.Navigate().GoToUrl("http://cabinet.alitrack.ru/tracking/");
                    WaitForCompleteXPath(browser, "//a[contains(@href,'tracking')]");
                    var trackingNewRows = browser.FindElementsByClassName("tracking-row");
                    Regex regexButtons = new Regex("<div[^>]*class=\"buttons\"[^>]*>(.*?)</div>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                    Regex regexFull = new Regex("<div[^>]*class=\"fullinfo\"[^>]*>(.*?)</div>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                    int newCount = 0;
                    StringBuilder newItems = new StringBuilder();
                    foreach (var trackingRow in trackingNewRows)
                    {
                        Console.WriteLine(trackingRow.FindElement(By.ClassName("name")).Text);
                        if (!string.IsNullOrEmpty(trackingRow.FindElement(By.ClassName("newSteps")).Text))
                        {
                            newCount++;
                            newItems.AppendLine(regexFull.Replace(regexButtons.Replace(trackingRow.GetAttribute("outerHTML"), string.Empty), string.Empty));
                        }
                    }
                    #endregion

                    if (newCount > 0)
                    {
                        #region Processing
                        newItems.Replace("class=\"clear\"", "style=\"clear: both;\"");
                        newItems.Replace("class=\"newSteps\"", "style=\"font-size: 11px;font-weight: normal;color: #a00;display: inline-block;padding: 0 0 0 4px;margin: -5px 0 0 0;vertical-align: top;\"");
                        newItems.Replace("class=\"info\"", "style=\"padding: 0;	overflow: hidden;	white-space: nowrap;color: #50749b;\"");
                        newItems.Replace("class=\"meta\"", "style=\"padding: 3px 0 0 0;	display:inline-block;overflow: hidden;color: #97adc3;white-space: nowrap;\"");
                        newItems.Replace("class=\"name\"", "style=\"font-size: 18px; padding: 9px 0 5px 0; overflow: hidden; color: #50749b; cursor: pointer; white-space: nowrap;\"");

                        newItems.Replace("class=\"tracking-row hasmoves\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #d0e7ff;	border-radius: 5px;\"");
                        newItems.Replace("class=\"tracking-row hasexport\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #bad2ff;	border-radius: 5px;\"");
                        newItems.Replace("class=\"tracking-row haslong\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #c0b4ff;	border-radius: 5px;\"");
                        newItems.Replace("class=\"tracking-row hascustom\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #e6ff8c;	border-radius: 5px;\"");
                        newItems.Replace("class=\"tracking-row hasnotrace\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #ffc994; border-radius: 5px;\"");
                        newItems.Replace("class=\"tracking-row hasnative\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #b3fab3;	border-radius: 5px;\"");
                        newItems.Replace("class=\"tracking-row hasarrive\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #161; color: #b3fab3; border-radius: 5px;\"");
                        newItems.Replace("class=\"tracking-row haswarning\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #ffd0d0; color: #50749B; border-radius: 5px;\"");
                        newItems.Replace("class=\"tracking-row hasrecieved\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #DDD;	border-radius: 5px;\"");


                        newItems.Replace("class=\"tracking-row\"", "style=\"font-family: Arial, Verdana, Tahoma; font-size: 12px; line-height: 1em; margin: 0 0 2px 0; background-color: #ebeff3; border-radius: 5px;\"");

                        newItems.Replace("class=\"main\"", "style=\"padding: 0 0 8px 8px; float: left; background-color: #ebeff3; border-radius: 0 5px 5px 0; cursor: pointer; position: relative;\"");
                        newItems.Replace("class=\"time\"", "style=\"font-size: 10px; line-height: 10px; color: #50749b; text-align: center; padding: 35px 0 0;\"");
                        newItems.Replace("class=\"icon\" style=\"", "style=\"float: left;width: 60px;height: 60px;border-radius: 5px 0 0 5px; overflow: hidden; cursor: default;background: url(trackicons/0.png) 14px 5px no-repeat;");
                        newItems.Replace(" class=\"infopos\"", string.Empty);
                        #endregion

                        #region Send report
                        string report = cabinet.alitrack.ru.Properties.Resources.Template.Replace("{NEW}", newItems.ToString());
                        SmtpClient client = new SmtpClient(cabinet.alitrack.ru.Properties.Settings.Default.SMTP);
                        MailAddress from = new MailAddress(cabinet.alitrack.ru.Properties.Settings.Default.EmailFrom);
                        MailAddress to = new MailAddress(cabinet.alitrack.ru.Properties.Settings.Default.EmailTo);
                        MailMessage message = new MailMessage(from, to);
                        message.Subject = string.Format("{0} new update from alitrack", newCount);
                        message.IsBodyHtml = true;
                        message.Body = report;
                        client.Send(message);
//.........这里部分代码省略.........
开发者ID:rechkin,项目名称:cabinet.alitrack.ru,代码行数:101,代码来源:Program.cs


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