當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。