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


C# Firefox.FirefoxDriver类代码示例

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


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

示例1: GetBrowser

 public static RemoteWebDriver GetBrowser()
 {
     //return new PhantomJSDriver(); // faster
     var result = new FirefoxDriver(); // easier debugging
     result.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
     return result;
 }
开发者ID:Natsui31,项目名称:keyhub,代码行数:7,代码来源:BrowserUtil.cs

示例2: EnsureDriverIsInitialised

 public static void EnsureDriverIsInitialised()
 {
     if (CurrentDriver == null)
     {
       CurrentDriver = new FirefoxDriver();
     }
 }
开发者ID:DivyaPathuri,项目名称:MoonPigSearch,代码行数:7,代码来源:BaseHelper.cs

示例3: GetConfigBrowser

        public static IWebDriver GetConfigBrowser(string browserName)
        {
            string AppRoot = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string strDriverPath = null;
            IWebDriver webDriver = null;
            if (browserName.Equals("Firefox", StringComparison.InvariantCultureIgnoreCase))
            {
                webDriver = new FirefoxDriver();
            }
            else if (browserName.Equals("chrome", StringComparison.InvariantCultureIgnoreCase))
            {
                strDriverPath = Path.Combine(AppRoot, @"CodedUITests\Drivers\chromedriver_win32");
                webDriver = new ChromeDriver(strDriverPath);

            }
            else if (browserName.Equals("IE", StringComparison.InvariantCultureIgnoreCase))
            {
                InternetExplorerOptions options = new InternetExplorerOptions()
                {
                    EnableNativeEvents = true,
                    IgnoreZoomLevel = true
                };
                strDriverPath = Path.Combine(AppRoot, @"CodedUITests\Drivers\IEDriverServer_Win32_2.44.0");
                webDriver = new InternetExplorerDriver(strDriverPath, options, TimeSpan.FromMinutes(3.0));
            }
            if (webDriver == null)
                throw new Exception("must configure browsername in aap.config");
            else
                return webDriver;
        }
开发者ID:wpdiary,项目名称:PolyGlotPersistence,代码行数:30,代码来源:BrowserSelect.cs

示例4: WindowProcess_Demo2

        public void WindowProcess_Demo2()
        {
            var articleName = "[小北De编程手记] : Lesson 02 - Selenium For C# 之 核心对象";

            _output.WriteLine("Step 01 : 启动浏览器并打开Lesson 01 - Selenium For C#");
            IWebDriver driver = new FirefoxDriver();
            driver.Url = "http://www.cnblogs.com/NorthAlan/p/5155915.html";

            _output.WriteLine("Step 02 : 点击链接打开新页面。");
            var lnkArticle02 = driver.FindElement(By.LinkText(articleName));
            lnkArticle02.Click();

            _output.WriteLine("Step 03 : 根据标题获取新页面的句柄。");
            var oldWinHandle = driver.CurrentWindowHandle;
            foreach (var winHandle in driver.WindowHandles)
            {
                driver.SwitchTo().Window(winHandle);
                if (driver.Title.Contains(articleName))
                {
                   break;
                }
            }

            _output.WriteLine("Step 04 : 验证新页面标题是否正确。");
            var articleTitle = driver.FindElement(By.Id("cb_post_title_url"));
            Assert.Equal<string>(articleName, articleTitle.Text);

            _output.WriteLine("Step 05 : 关闭浏览器。");
            driver.Quit();

        }
开发者ID:DemoCnblogs,项目名称:Selenium,代码行数:31,代码来源:Lesson07_WindowProcess.cs

示例5: SimpleNavigationTest

        public void SimpleNavigationTest()
        {
            // Create a new instance of the Firefox driver.

            // Notice that the remainder of the code relies on the interface,
            // not the implementation.

            // Further note that other drivers (InternetExplorerDriver,
            // ChromeDriver, etc.) will require further configuration
            // before this example will work. See the wiki pages for the
            // individual drivers at http://code.google.com/p/selenium/wiki
            // for further information.
            IWebDriver driver = new FirefoxDriver();

            //Notice navigation is slightly different than the Java version
            //This is because 'get' is a keyword in C#
            driver.Navigate().GoToUrl("http://www.google.com/");

            // Find the text input element by its name
            IWebElement query = driver.FindElement(By.Name("q"));

            // Enter something to search for
            query.SendKeys("Cheese");

            // Now submit the form. WebDriver will find the form for us from the element
            query.Submit();

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

            //Close the browser
            driver.Quit();
        }
开发者ID:kostyrin,项目名称:FNHMVC,代码行数:35,代码来源:NavigationTest.cs

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

示例7: SingUp_TestUser_FindNameInHelloString

        public void SingUp_TestUser_FindNameInHelloString()
        {
            firefox = new FirefoxDriver();
            firefox.Navigate().GoToUrl("http://localhost:57336/");
            firefox.FindElement(By.Id("register")).Click();

            //register page
            firefox.FindElement(By.Id("inputFirstName")).SendKeys("testFirstName");
            firefox.FindElement(By.Id("inputLastName")).SendKeys("testLastName");
            firefox.FindElement(By.Id("inputEmail")).SendKeys("[email protected]");
            firefox.FindElement(By.Id("inputPassword")).SendKeys("123");
            firefox.FindElement(By.Id("submit")).Click();
            firefox.FindElement(By.Id("login")).Click();

            //log in page
            firefox.FindElement(By.Id("inputEmail")).SendKeys("[email protected]");
            firefox.FindElement(By.Id("inputPassword")).SendKeys("123");
            firefox.FindElement(By.Id("login")).Click();

            firefox.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            string helloString = firefox.FindElement(By.Id("helloString")).Text;
            string result = "Hello, testFirstName testLastName";

            //delete test user
            firefox.Navigate().GoToUrl("http://localhost:57336/User/UsersProfile");
            firefox.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            firefox.FindElement(By.Id("deleteProfile")).Click();

            Assert.IsTrue(result == helloString);
        }
开发者ID:aminternship2015,项目名称:team04,代码行数:30,代码来源:UserControllerTests.cs

示例8: testHomePage

        /// <summary>
        /// Test all links on the Krossover home page
        /// </summary>
        public void testHomePage(FirefoxDriver driver)
        {
            string homePage = "http://www.krossover.com/";
            driver.Navigate().GoToUrl(homePage);
            Thread.Sleep(1000);

            //find all links on the page
            IList<IWebElement> links = driver.FindElementsByTagName("a");

            //loop through all of the links on the page
            foreach (IWebElement link in links)
            {
                try
                {
                    //check if any of the links return a 404
                    link.SendKeys(Keys.Control + Keys.Enter);
                    driver.SwitchTo().Window(driver.WindowHandles.Last());

                    driver.FindElementByXPath("//div[contains(@class, '404')]");
                    log(link.GetAttribute("href") + " is broken.  Returned 404");

                    driver.SwitchTo().Window(driver.WindowHandles.First());
                }
                catch
                {
                    //continue to the next link
                    continue;
                }

            }
            driver.Quit(); //kill the driver
        }
开发者ID:dhruv0018,项目名称:Krossover,代码行数:35,代码来源:TestHomePage.cs

示例9: OneCanLoginStackoverflow

 public void OneCanLoginStackoverflow()
 {
     IWebDriver driver = new FirefoxDriver();
     StartPage startPage = new StartPage(driver);
     String title = startPage.OpenPage().SignIn().Login(USERNAME, PASSWORD).GetPageTitle();
     Console.WriteLine(title);
 }
开发者ID:VladislavParkhutich,项目名称:StackoverflowAutomation,代码行数:7,代码来源:StackoverflowTest.cs

示例10: RunSalesExecutive

        // GET: RunSystemAdministrator
        public ActionResult RunSalesExecutive()
        {
            IWebDriver driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://localhost:4601/");
            var emp = _employeeService
                             .Queryable()
                             .Where(x => x.DepartmentRoleId == 10)
                             .FirstOrDefault ();
            emp.EmployeeLogin = _employeeLoginService
                                .Queryable()
                                .Where(x => x.EmployeeId == emp.EmployeeId)
                                .FirstOrDefault();
            IWebElement UserName = driver.FindElement(By.Name("UserName"));
            IWebElement Password = driver.FindElement(By.Name("Password"));
            var loginButton = driver.FindElement(By.XPath("/html/body/div/div/div/section/form/button"));

            UserName.SendKeys(emp.EmployeeLogin.UserName);
            Password.SendKeys(emp.EmployeeLogin.Password);
            loginButton.Click();

            Timer timer = new Timer(1000);
            timer.Start();

            timer.Stop();
            return View();
        }
开发者ID:NhlaksMaestro,项目名称:RoleBasedRateSystemSolution,代码行数:27,代码来源:AutomationController.cs

示例11: CreateWebDriver

        private static IWebDriver CreateWebDriver()
        {
            IWebDriver driver = null;

            var type = ConfigurationManager.AppSettings["WebDriver"];
            switch (type)
            {
                case "Firefox":
                    {
                        var firefoxProfile = new FirefoxProfile
                        {
                            AcceptUntrustedCertificates = true,
                            EnableNativeEvents = true
                        };
                        driver = new FirefoxDriver(firefoxProfile);

                        break;
                    }
                case "Chrome":
                case "InternetExplorer":
                    // TODO
                    break;
                default:
                    throw new NotSupportedException();
            }
            return driver;
        }
开发者ID:sergiofagostinho,项目名称:netponto.specflow,代码行数:27,代码来源:WebDriverFactory.cs

示例12: Add_Tweet_FindNewTweetInNewsfeed

        public void Add_Tweet_FindNewTweetInNewsfeed()
        {
            firefox = new FirefoxDriver();
            firefox.Navigate().GoToUrl("http://localhost:57336/");
            //firefox.FindElement(By.Id("register")).Click();
            firefox.FindElement(By.Id("login")).Click();

            //register page
            //firefox.FindElement(By.Id("inputFirstName")).SendKeys("testFirstName");
            //firefox.FindElement(By.Id("inputLastName")).SendKeys("testLastName");
            //firefox.FindElement(By.Id("inputEmail")).SendKeys("[email protected]");
            //firefox.FindElement(By.Id("inputPassword")).SendKeys("123");
            //firefox.FindElement(By.Id("submit")).Click();
            //firefox.FindElement(By.Id("login")).Click();

            //log in page
            firefox.FindElement(By.Id("inputEmail")).SendKeys("[email protected]");
            firefox.FindElement(By.Id("inputPassword")).SendKeys("123");
            firefox.FindElement(By.Id("login")).Click();

            firefox.FindElement(By.Name("Body")).Click();
            firefox.FindElement(By.Name("Body")).SendKeys("test Tweet");

            firefox.FindElement(By.Id("tweetbutton")).Click();
            firefox.FindElement(By.Id("home")).Click();

            string tweetMessage = firefox.FindElement(By.TagName("h5")).Text;

            Assert.IsTrue(tweetMessage == "test Tweet");
        }
开发者ID:vlad94md,项目名称:team04,代码行数:30,代码来源:TweetControllerTests.cs

示例13: CreateWebDriver

 public IWebDriver CreateWebDriver()
 {
     var driver = new FirefoxDriver();
     driver.Manage().Window.Maximize();
     driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
     return driver;
 }
开发者ID:xcyroo,项目名称:InnovationDay.AcceptanceTesting,代码行数:7,代码来源:LocalFirefoxEnvironment.cs

示例14: CreateExamSchemaTest

        public void CreateExamSchemaTest()
        {
            IWebDriver driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://dev.chd.miraclestudios.us/probo-php/admin/apps/backend/site/login");
            driver.FindElement(By.Id("UserLoginForm_username")).Clear();
            driver.FindElement(By.Id("UserLoginForm_username")).SendKeys("owner");
            driver.FindElement(By.Id("UserLoginForm_password")).Clear();
            driver.FindElement(By.Id("UserLoginForm_password")).SendKeys("ZFmS!H3*wJ2~^S_zx");
            driver.FindElement(By.Id("login-content-button")).Click();

            System.Threading.Thread.Sleep(2000);

            driver.FindElement(By.LinkText("Manage Examination")).Click();
            driver.FindElement(By.LinkText("Manage Exam Scheme")).Click();
            System.Threading.Thread.Sleep(2000);
            driver.FindElement(By.LinkText("Create Exam Scheme")).Click();
            System.Threading.Thread.Sleep(5000);
            Random rnd = new Random();

            new SelectElement(driver.FindElement(By.Id("PrbExamScheme_exam_category_id"))).SelectByText("Food Safety");

            new SelectElement(driver.FindElement(By.Id("levelid"))).SelectByText("Project Manager3610");
            driver.FindElement(By.Id("PrbExamScheme_scheme_name")).Clear();
            driver.FindElement(By.Id("PrbExamScheme_scheme_name")).SendKeys("ISO softengineering" + rnd.Next(1, 1000));
            driver.FindElement(By.Name("yt0")).Click();

            string URL = driver.Url;
            Assert.AreNotEqual("http://dev.chd.miraclestudios.us/probo-php/admin/apps/backend/probo/competencyDomain/view/id/", URL.Substring(0, 89));
            driver.Quit();
        }
开发者ID:therider,项目名称:Jenkins,代码行数:30,代码来源:Testi1.cs

示例15: Attack2_NonProtected

        public void Attack2_NonProtected()
        {
            IWebDriver driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://localhost/LU.ENGI3675.Project04/StudentInputUNSAFE.aspx");

            IWebElement query = driver.FindElement(By.Name("fullNameUS"));

            query.SendKeys("a','2.1'); update students * set gpa = 4.0; --");
            query = driver.FindElement(By.Name("GPAUS"));
            query.SendKeys("0");
            query = driver.FindElement(By.Name("button"));
            query.Click();
            System.Threading.Thread.Sleep(1000);

            List<LU.ENGI3675.Proj04.App_Code.Students> students =
                LU.ENGI3675.Proj04.App_Code.DatabaseAccess.Read();

            foreach (LU.ENGI3675.Proj04.App_Code.Students temp in students)
            {
                Assert.IsTrue((double)temp.GPA == 4);   //if any of them aren't 4.0, injection failed
                Debug.Write((string)temp.Name);
                Debug.Write(" ");
                Debug.WriteLine((double)temp.GPA);
            }
            driver.Quit();
        }
开发者ID:shojimonk,项目名称:Databases-Project-4,代码行数:26,代码来源:UnitTest1.cs


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