コード例 #1
1
 public static IWebDriver GetDriver(string driver, Devices device)
 {
     DeviceModel model = Device.Get(device);
     IWebDriver webDriver;
     switch (driver.ToLower())
     {
         case "safari":
             webDriver = new SafariDriver();
             break;
         case "chrome":
             webDriver = new ChromeDriver();
             break;
         case "ie":
             webDriver = new InternetExplorerDriver();
             break;
         //case "firefox":
         default:
             var profile = new FirefoxProfile();
             profile.SetPreference("general.useragent.override", model.UserAgent);
             webDriver = new FirefoxDriver(profile);
             webDriver.Manage().Window.Size = model.ScreenSize;
             break;
     }
     return webDriver;
 }
 public IWebDriver CreateWebDriver()
 {
     var driver = new FirefoxDriver();
     driver.Manage().Window.Maximize();
     driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
     return driver;
 }
コード例 #3
0
        public void SingUp_TestUser_FindNameInHelloString()
        {
            firefox = new FirefoxDriver();
            firefox.Navigate().GoToUrl("http://*****:*****@mail.com");
            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("*****@*****.**");
            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);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://www.seleniummaster.com/");

            driver.Manage().Window.Maximize();

            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            IWebElement menu = driver.FindElement(By.Id("menubar"));
            Actions builder = new Actions(driver);
            builder.MoveToElement(menu).Build().Perform();

            IList<IWebElement> menuItemsList = menu.FindElements(By.Id("menu"));
            char[] delim = { '\r', '\n' };
            String[] menuList = menuItemsList[0].Text.Split(delim);

            //Query to orderby all the list items
            IEnumerable<string> orderedMenuList = menuList.OrderBy(lv_menu => lv_menu).ToList();

            //Display the ordered list
            foreach (string menuItem in orderedMenuList)
            {
                if (menuItem.Length > 0)
                    Console.WriteLine(menuItem);
            }
            Console.ReadKey();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://www.integrationqa.com/");

            driver.Manage().Window.Maximize();

            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            IWebElement menu = driver.FindElement(By.Id("hs_menu_wrapper_module_13970568219884"));
            Actions builder = new Actions(driver);
            builder.MoveToElement(menu).Build().Perform();

            IList<IWebElement> menuItemsList = menu.FindElements(By.ClassName("hs-menu-item"));

            String[] menuItems = new String[menuItemsList.Count];
            int i = 0;
            foreach (IWebElement menuItem in menuItemsList)
            {
                menuItems[i++] = menuItem.Text;
            }

            //Arrange all the list items in alphabetical order
            IEnumerable<String> orderedMenuList = menuItems.OrderBy(lv_menu => lv_menu).ToList();

            //Display the ordered list
            foreach (var menuItem in orderedMenuList)
            {
                if (menuItem.Length > 0)
                    Console.WriteLine(menuItem);
            }
            Console.ReadKey();
        }
コード例 #6
0
 public IWebDriver CreateWebDriver()
 {
     var driver = new FirefoxDriver();
     driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(2000));
     driver.Manage().Window.Maximize();
     return driver;
 }
コード例 #7
0
ファイル: WebDriverExtensions.cs プロジェクト: c0d3m0nky/mty
        /// <summary>
        ///   Yahoo overrides standard DOM event methods (i.e. onclick("", ...)) causing webdriver to trigger unexpected memory protection exceptions 
        /// </summary>
        public static IWebDriver CreateWithDefaultProperties()
        {
            var caps = new OpenQA.Selenium.Remote.DesiredCapabilities();
            caps.SetCapability(OpenQA.Selenium.Remote.CapabilityType.HasNativeEvents, false);
            
            var driver = new FirefoxDriver(caps);
            driver.Manage().Window.Maximize();
            driver.Manage().Cookies.DeleteAllCookies();

            return driver;
        }
コード例 #8
0
ファイル: Constants.cs プロジェクト: anapsousa/Springer
        public static IWebDriver FirefoxBrowser()
        {
            IWebDriver driver;

            driver = new FirefoxDriver();
            driver.Manage().Window.Maximize();
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            driver.Navigate().GoToUrl(BaseURL);

            return driver;
        }
コード例 #9
0
 public override IWebDriver CreateDriver()
 {
     Console.WriteLine("Create Factory FF WD");
     FirefoxProfile profile = new FirefoxProfile();
     profile.EnableNativeEvents = true;
     profile.DeleteAfterUse = true;
     IWebDriver factoryDriver = new FirefoxDriver(profile);
     factoryDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
     factoryDriver.Manage().Window.Maximize();
     return factoryDriver;
 }
コード例 #10
0
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            int idInicio = 30000;
            int idFinal = 22000;
            int contador = 1;
            String url = "";

            driver.Navigate().GoToUrl(url + idInicio);
            driver.Manage().Window.Maximize();
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"e:\AllStudents.csv", true))
            {

                while (idInicio > idFinal)
                {
                    driver.Navigate().GoToUrl(url + idInicio);
                    IWebElement nome = driver.FindElement(By.Id("txtNome"));
                    IWebElement email = driver.FindElement(By.Id("txtmail_maior"));
                    if (email.GetAttribute("value").ToString() != "")
                    {
                        Console.WriteLine(contador + " - " + idInicio.ToString() + " - " + nome.GetAttribute("value").ToString() + " - " + email.GetAttribute("value").ToString());
                        file.WriteLine(contador + ";" + idInicio.ToString() + ";" + email.GetAttribute("value").ToString() +";"+ nome.GetAttribute("value").ToString());

                        contador++;
                    }
                    idInicio--;
                }
            }
        }
コード例 #11
0
        public void SetUp()
        {
            IWebDriver driver = new FirefoxDriver();
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            browser = new Browser(driver);
        }
コード例 #12
0
 static void Main(string[] args)
 {
     try
         {   // Instantiating variables
             string[] theURLs = new string[3];
             string[] theCriteria = new string[3];
             int wi, milsec=2500;
             // Instantiating classes
             IWebDriver wbDriver = new FirefoxDriver();
             TheWebURLs webI=new TheWebURLs();
             LoggingStuff logMe = new LoggingStuff();
             wbDriver.Manage().Window.Maximize();
             // Setting values for variables
             theURLs=webI.getTheURLs();
             theCriteria=webI.getSearchCiteria();
             string logPath = logMe.createLogName().ToString();
             /**********************************************/
             // Run Test
             logMe.writeFile("Selenium Test Log", false, logPath);
             for(wi = 0; wi < 3; wi++)
             {   // Opens the various web pages
                 Console.WriteLine(theURLs[wi] + ", " + theCriteria[wi]);
                 logMe.writeFile(theURLs[wi] + ", " + theCriteria[wi], true, logPath);
                 wbDriver.Navigate().GoToUrl(theURLs[wi]);
                 Thread.Sleep(milsec*2);
             }
             wbDriver.Quit();
         }
     catch (IOException e3)
     {
         Console.WriteLine("Failed during Main",e3.Message);
     }
 }
コード例 #13
0
ファイル: BrowserUtil.cs プロジェクト: Natsui31/keyhub
 public static RemoteWebDriver GetBrowser()
 {
     //return new PhantomJSDriver(); // faster
     var result = new FirefoxDriver(); // easier debugging
     result.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
     return result;
 }
コード例 #14
0
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();
            const int idInicio = 0;
            const int idFim = 1000;

            int id = idInicio;
            String url = "http://fcv.matheusacademico.com.br/Aluno/frmAlunoAlteracao.asp?id=";

            driver.Navigate().GoToUrl(url + id);
            driver.Manage().Window.Maximize();

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"c:\AllStudents1.txt", true))
            {
                while (id < idFim)
                {
                    driver.Navigate().GoToUrl(url + id);
                    IWebElement nome = driver.FindElement(By.Id("txtNome"));
                    IWebElement email = driver.FindElement(By.Id("txtmail_maior"));

                    if (nome.GetAttribute("value").ToString() != "")
                        file.WriteLine(id.ToString() + " - " + nome.GetAttribute("value").ToString() + " - " + email.GetAttribute("value").ToString());
                    id++;
                }
            }
        }
コード例 #15
0
ファイル: UnitTest1.cs プロジェクト: tking16/Selenium
 public void PostToBlog()
 {
     IWebDriver browser = new FirefoxDriver();
     browser.Navigate().GoToUrl("http://tumblr.com/login");
     IWebElement email = browser.FindElement(By.Id("signup_determine_email"));
     email.SendKeys("*****@*****.**");
     IWebElement verifyButton = browser.FindElement(By.Id("signup_forms_submit"));
     verifyButton.Click();
     browser.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
     IWebElement password = browser.FindElement(By.Id("signup_password"));
     password.SendKeys("******");
     IWebElement loginButton = browser.FindElement(By.Id("signup_forms_submit"));
     loginButton.Click();
     IWebElement textIcon = browser.FindElement(By.ClassName("icon_post_text"));
     textIcon.Click();
     IWebElement postTitle = browser.FindElement(By.ClassName("editor-plaintext"));
     postTitle.SendKeys("c# selenium");
     IWebElement postBody = browser.FindElement(By.ClassName("editor-richtext"));
     postBody.SendKeys("this is a c# with selenium test");
     IWebElement createPost = browser.FindElement(By.ClassName("create_post_button"));
     createPost.Click();
     //TearDown
     IWebElement postSettings = browser.FindElement(By.ClassName("post_control_menu"));
     postSettings.Click();
     IWebElement postDelete = browser.FindElement(By.ClassName("delete"));
     postDelete.Click();
     IWebElement okButton = browser.FindElement(By.ClassName("btn_1"));
     okButton.Click();
     IWebElement accountButton = browser.FindElement(By.ClassName("icon_user_settings"));
     browser.Close();
 }
コード例 #16
0
ファイル: FirefoxDriver.cs プロジェクト: sasviben/web.test.UI
        public IWebDriver LoadFirefoxDriver(bool headless = false)
        {
            var driverService = FirefoxDriverService.CreateDefaultService(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            try
            {
                driverService.HideCommandPromptWindow = true;
                driverService.Host = "::1";

                var options = new FirefoxOptions();
                options.AddArgument("--disable-extensions");
                options.AddArgument("--disable-popup-blocking");
                options.AddArgument("--window-size=1920,1080");
                options.AddArguments("--disable-infobars");

                if (headless == true)
                {
                    options.AddArgument("headless");
                }

                var driver = new OpenQA.Selenium.Firefox.FirefoxDriver(driverService, options);
                driver.Manage().Window.Maximize();
                return(driver);
            }
            catch (WebDriverException we)
            {
                throw new WebDriverException(we.Message);
            }
        }
コード例 #17
0
 public void FirefoxStartup()
 {
     FirefoxDriver dr = new FirefoxDriver();
     dr.Manage().Window.Maximize();
     dr.Navigate().GoToUrl(url);
     dr.Quit();
 }
コード例 #18
0
ファイル: HomePageTests.cs プロジェクト: dwwhalen/SimplyLists
        public void LogonTest()
        {
            IWebDriver driver = new FirefoxDriver();
            //IWebDriver driver = new ChromeDriver();
            //IWebDriver driver = new InternetExplorerDriver();
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            //ChromeDriver driver = new ChromeDriver();
            string homepageURL = "https://*****:*****@gmail.com", "F5ft2mz0_");

            //verify the user is logged in
            Assert.IsTrue(indexPageObject.CheckAuthentication(true));

            //driver.Close();
        }
コード例 #19
0
ファイル: SelMetody.cs プロジェクト: marcinkoczan/selenium
 public static IWebDriver ConfigureDriver(IWebDriver driver, string driverType, string driverPath)
 {
     switch (driverType)
     {
         case "ie":
             {
                 driver = new InternetExplorerDriver(driverPath);
                 driver.Manage().Window.Maximize();
                 return driver;
             }
         case "firefox":
             {
                 driver = new FirefoxDriver();
                 driver.Manage().Window.Maximize();
                 return driver;
             }
         case "chrome":
             {
                 driver = new ChromeDriver(driverPath);
                 driver.Manage().Window.Maximize();
                 return driver;
             }
     }
     return driver;
 }
コード例 #20
0
        public void Setup()
        {
            // инициализируем драйвер
            driver = new FirefoxDriver();

            //указываем ожидание появления элементов в 5 секунд (0 по умолчанию)
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
        }
コード例 #21
0
 public static IWebDriver getFirefoxDriver()
 {
     FirefoxProfile profile = new FirefoxProfile();
     profile.SetPreference("network.proxy.type", 0);
     IWebDriver driver = new FirefoxDriver(profile);
     driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(waitsec));
     return driver;
 }
コード例 #22
0
ファイル: CommonSteps.cs プロジェクト: OlegKleyman/Adilicious
        public static void Setup()
        {
            var driver = new FirefoxDriver();
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            var site = new AdiliciousWebsite(driver);
            site.Start(defaultPort);
            FeatureContext.Current.Set(site);
        }
コード例 #23
0
 public void startBrowser()
 {
     FirefoxDriver w = new FirefoxDriver();
     // Added Comment
     w.Url = uploadLocation;
     w.Manage().Window.Maximize();
     Thread.Sleep(5000);
     w.Quit();
 }
コード例 #24
0
 public void GivenThatIAmAtTheWebsite(string url)
 {
     IWebDriver driver = new FirefoxDriver();
     driver.Navigate().GoToUrl(url);
     driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
     homePage = driver.Url;
     ScenarioContext.Current.Add("driver", driver);
     Assert.AreEqual("Sally's Puppy Adoption Agency", driver.Title);
 }
コード例 #25
0
 public void Test2()
 {
     var driver = new FirefoxDriver();
     driver.Navigate().GoToUrl("http://www.qtptutorial.net/automation-practice");
     driver.Manage().Window.Maximize();
     driver.FindElementByClassName("buttonClassExample").Click();
     var elementCheck = driver.FindElementByXPath("//p[contains(text(),'Button success')]").Displayed;
     Assert.IsFalse(elementCheck, "Element was not present");
 }
コード例 #26
0
        public void TestFlowControl_Demo1()
        {
            IWebDriver driver = new FirefoxDriver();   
            // 1. 隐式的等待 同步测试
            driver.Manage().Timeouts()
                .ImplicitlyWait(TimeSpan.FromSeconds(10))
                .SetPageLoadTimeout(TimeSpan.FromSeconds(10))
                .SetScriptTimeout(TimeSpan.FromSeconds(10));

            driver.Close();
        }
コード例 #27
0
ファイル: Driver.cs プロジェクト: anthony-lavallee/miam
        public static void Initialize()
        {
            Instance = new FirefoxDriver();
            
            //Selenium doit attendre 5 secondes avant d'indiquer qu'un objet n'est pas sur une page.
            Instance.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

            //Efface et peuple la BD avec des données pour les tests
            Instance.Navigate().GoToUrl(BaseAddress + "/Ci");
            Instance.FindElement(By.Id("go_home")).Click();
        }
コード例 #28
0
        public void Apply_RedirectToApplyFromSignInPage_ShouldPassTest()
        {
            using (IWebDriver wdriver = new FirefoxDriver())
            {
                wdriver.Navigate().GoToUrl("https://softuni.bg");
                wdriver.Manage().Window.Maximize();
                wdriver.FindElement(By.Id("loginLink")).Click();

                Assert.AreEqual(wdriver.Url, "https://softuni.bg/account/authenticate");
                wdriver.Quit();
            }
        }
コード例 #29
0
ファイル: Program.cs プロジェクト: juni-j/arf
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://www.bing.com");
            driver.Manage().Window.Maximize();

            IWebElement searchInput = driver.FindElement(By.Id("sb_form_q"));
            searchInput.SendKeys("cute seals");
            searchInput.SendKeys(Keys.Enter);
            driver.Close();
        }
コード例 #30
0
 public void EndToEnd()
 {
     const string iisexpress = "iisexpress";
     Process iis = null;
     var iises = Process.GetProcessesByName(iisexpress);
     while (iises.Length > 0)
     {
         iis = iises[0];
         iis.Kill();
         iis.WaitForExit();
         iises = Process.GetProcessesByName(iisexpress);
     }
     iis = new Process();
     try
     {
         iis.StartInfo.FileName = @"C:\Program Files\IIS Express\iisexpress.exe";
         iis.StartInfo.Arguments = "/site:Website1";
         iis.Start();
         using (var driver = new ChromeDriver())
         {
             EndToEnd(driver);
         }
         using (var driver = new FirefoxDriver())
         {
             EndToEnd(driver);
         }
         var profile = new FirefoxProfile();
         profile.SetPreference
         (
             "general.useragent.override",
             "Mozilla/5.0 (iPhone; CPU iPhone OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) GSA/8.0.57838 Mobile/12H321 Safari/600.1.4"
         );
         using (var driver = new FirefoxDriver(profile))
         {
             var options = driver.Manage();
             options.Window.Size = new Size { Width = 100, Height = 550};
             driver.Url = url;
             TestNavigationMobile(driver, instructions, howToUse);
             TestNavigationMobile(driver, home, enterNumber);
             TestNavigation(driver, nsc, enterNumber);
             TestCalc(driver);
             TestNavigationMobile(driver, contact, contactDetails);
         }
         using (var driver = new InternetExplorerDriver())
         {
             EndToEnd(driver);
         }
     }
     finally
     {
         iis.CloseMainWindow();
     }
 }
コード例 #31
0
ファイル: CodedUITest1.cs プロジェクト: juni-j/arf
        public void SearchForCuteSealsGoogle()
        {
            IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://www.google.com");
            driver.Manage().Window.Maximize();

            IWebElement searchInput = driver.FindElement(By.Id("gbqfq"));
            searchInput.SendKeys("cute seals");
            searchInput.SendKeys(OpenQA.Selenium.Keys.Enter);
            driver.Close();
        }