Navigate() 공개 메소드

Method to allow you to Navigate with WebDriver.
public Navigate ( ) : INavigation
리턴 INavigation
        public void logging_in_with_invalid_credentials()
        {
            var capabilities = new DesiredCapabilities();
            capabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);

            var driver = new InternetExplorerDriver(capabilities);
            driver.Navigate().GoToUrl(TargetAppUrl + "/Authentication/LogOff");

            try
            {
                driver.Navigate().GoToUrl(TargetAppUrl + "/LogOn");

                driver.FindElement(By.Name("EmailAddress")).SendKeys("*****@*****.**");
                driver.FindElement(By.Name("Password")).SendKeys("BadPass");
                driver.FindElement(By.TagName("form")).Submit();

                driver.Url.ShouldEqual(TargetAppUrl + "/LogOn");

                driver.FindElement(By.ClassName("validation-summary-errors")).Text.ShouldContain(
                    "The user name or password provided is incorrect.");
            }
            finally
            {
                driver.Close();
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            //Create an instance of HTTPWatch Controller
            Controller control = new Controller();

            //Start IE Driver. IE Driver Server is located in C:\\
            IWebDriver driver = new InternetExplorerDriver(@"C:\");

            // Set a unique initial page title so that HttpWatch can attach to it
            string uniqueTitle = Guid.NewGuid().ToString();
            IJavaScriptExecutor js = driver as IJavaScriptExecutor;
            js.ExecuteScript("document.title = '" + uniqueTitle + "';");

            // Attach HttpWatch to the instance of Internet Explorer created through WebDriver
            Plugin plugin = control.AttachByTitle(uniqueTitle);

            //Open the HTTPWatch Window
            plugin.OpenWindow(false);

            //Navigate to the BMI Application Page
            driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/bmicalculator.html");

            //Perform some steps
            driver.FindElement(By.Id("heightCMS")).SendKeys("181");
            driver.FindElement(By.Id("weightKg")).SendKeys("80");
            driver.FindElement(By.Id("Calculate")).Click();

            //Export the HAR Log generated to a file
            plugin.Log.Save(@"C:\bmicalc.hwl");

            //Close the Internet Explorer
            driver.Close();
        }
        public void Should_page_through_items_in_IE()
        {
            IWebDriver ieDriver = new InternetExplorerDriver();
            ieDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            ieDriver.Navigate().GoToUrl("http://localhost:1392/");
            Login(ieDriver);

            ieDriver.FindElement(By.LinkText("Orders")).Click();

            for (int i = 0; i < 20; i++)
            {
                IWebElement nextButton = ieDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_ImageButtonNext"));

                nextButton.Click();

                IWebElement pageCount = ieDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_TextBoxPage"));

                int pageNumber = int.Parse(pageCount.GetAttribute("value"));

                Assert.AreEqual(i + 2, pageNumber);
            }

            ieDriver.FindElement(By.Id("LoginStatus1")).Click();
            ieDriver.Quit();
        }
예제 #4
0
 static void Main(string[] args)
 {
     try
     {
         var stopWatch = Stopwatch.StartNew();
         DesiredCapabilities capabilities = new DesiredCapabilities();
         var driverService = ChromeDriverService.CreateDefaultService(@"E:\");
         driverService.HideCommandPromptWindow = true;
         var webDriver = new InternetExplorerDriver();
         webDriver.Navigate().GoToUrl("http://www.udebug.com/UVa/10812");
         IWebElement inputBox = webDriver.FindElement(By.Id("edit-input-data"));
         inputBox.SendKeys("3\n2035415231 1462621774\n1545574401 1640829072\n2057229440 1467906174");
         IWebElement submitButton = webDriver.FindElement(By.Id("edit-output"));
         submitButton.SendKeys("\n");
         submitButton.Click();
         string answer = webDriver.PageSource;
         int begin = answer.IndexOf("<pre>") + 5;
         answer = answer.Substring(begin, answer.IndexOf("</pre>") - begin);
         Console.WriteLine(answer);
         webDriver.Close();
         Console.WriteLine(stopWatch.ElapsedMilliseconds);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.Message);
     }
 }
        public void when_logging_in_with_an_invalid_username_and_password()
        {
            var capabilities = new DesiredCapabilities();
            capabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);

            var driver = new InternetExplorerDriver(capabilities);

            try
            {
                driver.Navigate().GoToUrl("http://*****:*****@user.com");
                driver.FindElement(By.Name("Password")).SendKeys("BadPass");
                driver.FindElement(By.TagName("form")).Submit();

                driver.Url.ShouldEqual("http://localhost:52125/Account/LogOn");

                driver.FindElement(By.ClassName("validation-summary-errors")).Text.ShouldContain(
                    "The user name or password provided is incorrect.");
            }
            finally
            {
                driver.Close();
            }
        }
예제 #6
0
        public void GivenUserOpensMessagesSectionOnVKWebsite()
        {
            IWebDriver driver = new InternetExplorerDriver();

            ScenarioContext.Current.Add("driver", driver);

            driver.Navigate().GoToUrl("http://vk.com/im");
        }
예제 #7
0
        public void OpenGoogle()
        {
            IWebDriver driver = new InternetExplorerDriver();
            //IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://www.google.com/");
            IWebElement query = driver.FindElement(By.Name("q"));
            query.SendKeys("Cheese");
            System.Console.WriteLine("Page title is: " + driver.Title);
            // TODO add wait
            driver.Quit();
        }
    static void Main()
    {
        using (var driver = new OpenQA.Selenium.IE.InternetExplorerDriver())
        {
            driver.Navigate().GoToUrl("https://www.bing.com/");
            driver.FindElement(By.Id("sb_form_q")).SendKeys("Selenium WebDriver");
            driver.FindElement(By.Id("sb_form_go")).Click();

            Console.WriteLine("OK");
            Console.ReadKey(intercept: true);
        }
    }
예제 #9
0
        private static void crawlPartsbase()
        {
            IWebDriver driver = new InternetExplorerDriver(@"F:\IEDriverServer_x64_2.46.0");
            driver.Navigate().GoToUrl("http://www.partsbase.com/landing/login.asp");

            var usernameField = driver.FindElement(By.Name("username"));
            usernameField.SendKeys("tallaadmin");

            var passwdField = driver.FindElement(By.Name("password"));
            passwdField.SendKeys("Ta11a2015!");

            var submitBtn = driver.FindElement(By.XPath("//a[@class='btn btn-success' and @value='Log In']"));
            submitBtn.Click();
        }
 static void GetPageDetails(string[] allLinks, InternetExplorerDriver ieDriver, Stopwatch sw)
 {
     for (var i = 0; i < allLinks.Length; i++)
     {
         Console.WriteLine("Checking item no " + (i+1) + "/" + allLinks.Length);
         ieDriver.Navigate().GoToUrl(allLinks[i]);
         Thread.Sleep(1000);
         var tempApp = new AppDetail(ieDriver);
         Applications.Add(tempApp);
         Console.WriteLine("Checked URL in a total of " + sw.ElapsedMilliseconds + " milliseconds, eta for rest is " + sw.ElapsedMilliseconds*(allLinks.Length-(i+1)));
         sw.Restart();
     }
     Console.WriteLine("Retreived data from all items");
 }
        public void logging_in_with_no_credentials_displays_validation_error()
        {
            var capabilities = new DesiredCapabilities();
            capabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);

            var driver = new InternetExplorerDriver(capabilities);
            driver.Navigate().GoToUrl(TargetAppUrl + "/Authentication/LogOff");

            try
            {
                driver.Navigate().GoToUrl(TargetAppUrl + "/LogOn");

                driver.FindElement(By.TagName("form")).Submit();

                driver.Url.ShouldEqual(TargetAppUrl + "/LogOn");

                driver.FindElements(By.CssSelector("span.field-validation-error[data-valmsg-for=\"EmailAddress\"]")).ShouldNotBeEmpty();
                driver.FindElements(By.CssSelector("span.field-validation-error[data-valmsg-for=\"Password\"]")).ShouldNotBeEmpty();
            }
            finally
            {
                driver.Close();
            }
        }
예제 #12
0
        //tallaadmin
        //Ta11a2015!
        private static void CrawlILSmart()
        {
            IWebDriver driver = new InternetExplorerDriver(@"F:\IEDriverServer_x64_2.46.0");
            driver.Navigate().GoToUrl("http://static.ilsmart.com/pages/ILSLogin2014.htm?TabId=56&amp;language=en-US");

            //<iframe src="http://static.ilsmart.com/pages/ILSLogin2014.htm?TabId=56&amp;language=en-US" frameborder="0" style="width: 620px; height: 100px;" scrolling="no"></iframe>
            // <input tabindex="3" class="btn btn-primary btn-sm enter" type="submit" alt="Enter" value="Enter">
            var usernameField = driver.FindElement(By.Name("username"));
            usernameField.SendKeys("c08hu01");

            var passwdField = driver.FindElement(By.Name("password"));
            passwdField.SendKeys("Ta11a2015%");

            var submitBtn = driver.FindElement(By.XPath("//input[@type='submit' and @value='Enter']"));
            submitBtn.Click();
        }
예제 #13
0
        static void Main(string[] args)
        {
            var options = new InternetExplorerOptions
            {
                IgnoreZoomLevel = true
            };
            IWebDriver driver = new OpenQA.Selenium.IE.InternetExplorerDriver(options);

            driver.Navigate().GoToUrl("https://www.tomasvasquez.com.br/blog");

            IWebElement elemento = driver.FindElement(By.TagName("h1"));

            Console.WriteLine("O título do site é: {0}", elemento.Text);
            Console.Read();

            driver.Quit();
        }
예제 #14
0
        static void Main(string[] args)
        {
            IWebDriver driver = new InternetExplorerDriver();

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

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

            query.SendKeys("google test");

            query.Submit();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            wait.Until(t => t.Title.ToLower().StartsWith("google test"));

            System.Console.WriteLine(string.Format("Page title is: {0}", driver.Title));

            driver.Quit();
        }
		public void when_logging_in_with_a_valid_username_and_password()
		{
			var options = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true };
			var driver = new InternetExplorerDriver(options);

			try
			{
				driver.Navigate().GoToUrl("http://*****:*****@user.com");
				driver.FindElement(By.Name("Password")).SendKeys("RealPassword");
				driver.FindElement(By.TagName("form")).Submit();

				driver.Url.ShouldEqual("http://localhost:52125/");
			}
			finally
			{
				driver.Close();
			}
		}
예제 #16
0
        static void Run()
        {
            var driverService = InternetExplorerDriverService.CreateDefaultService();

            driverService.HideCommandPromptWindow = true;

            var chromeDriverService = ChromeDriverService.CreateDefaultService();

            chromeDriverService.HideCommandPromptWindow = true;



            using (IWebDriver driver = new OpenQA.Selenium.IE.InternetExplorerDriver(driverService, new InternetExplorerOptions()))
            {
                driver.Navigate().GoToUrl("http://www.baidu.com");  //driver.Url = "http://www.baidu.com"是一样的

                var source = driver.PageSource;

                Console.WriteLine(source);
            }
        }
예제 #17
0
        static TimeSpan Run(int times, bool enable)
        {
            var url = "http://localhost:52374/Home/Index";

            if (!enable)
            {
                url += "?enableTurbolinks=false";
            }

            Action<IFindsByLinkText> click = c => c.FindElementByLinkText("next").Click();

            using (var browser = new InternetExplorerDriver(

                new InternetExplorerOptions
                {
                    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                    IgnoreZoomLevel = true,
                    EnsureCleanSession = true
                }))
            {

                browser.Navigate().GoToUrl(url);

                // Warm up
                click(browser);

                var watch = new Stopwatch();

                watch.Start();

                for (var i = 0; i < times; i++)
                {
                    click(browser);
                }

                watch.Stop();

                return watch.Elapsed;
            }
        }
예제 #18
0
        static void Main(string[] args)
        {
            IWebDriver driver = new InternetExplorerDriver();

            driver.Navigate().GoToUrl("http://e1.englishtown.com/partner/coolschool/Default.aspx");

            IWebElement userNameQuery = driver.FindElement(By.Name("UserName"));
            IWebElement passwdQuery = driver.FindElement(By.Name("Password"));

            userNameQuery.SendKeys("cliu9800");
            passwdQuery.SendKeys("pass");

            IWebElement submitButton = driver.FindElement(By.Id("loginTrigger"));

            submitButton.Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            wait.Until(t => t.PageSource.ToLower().IndexOf("currentcourse") > 0);

            System.Console.WriteLine(string.Format("Page title is: {0}", driver.Title));

            driver.Quit();
        }
        public void CanGetTweetsOnDefaultPage()
        {
            IWebDriver driver = new InternetExplorerDriver();

            driver.Navigate().GoToUrl("http://*****:*****@id='results']/li"));
            IList<IWebElement> accounts = driver.FindElements(By.XPath("//div[@id='summary']//tr"));

            //Assert.AreEqual(1, results.Count);
            Assert.IsTrue(results.Count > 0);
            //Assert.AreEqual(1, accounts.Count);
            Assert.IsTrue(accounts.Count > 1);

            // Close the browser
            //driver.Quit();
        }
        static void Main(string[] args)
        {
            // Please keep your IE configuration settings:
            // 1. Check on "Enable Protected Mode" at ALL zones in "Security" tab of Internet Options dialog.
            // 2. Browser zoom level keep to 100%.
            var ieOptions = new InternetExplorerOptions
            {
                // Uncomment these lines if you use Microsoft Edge IE mode.
                // AttachToEdgeChrome = true,
                // EdgeExecutablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe",
                IgnoreZoomLevel = true,
            };

            using (var driver = new OpenQA.Selenium.IE.InternetExplorerDriver(ieOptions))
            {
                driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3);
                driver.Navigate().GoToUrl("https://www.bing.com/");
                driver.FindElement(By.Id("sb_form_q")).SendKeys("Selenium WebDriver");
                driver.FindElement(By.ClassName("search")).Click();

                Console.WriteLine("OK");
                Console.ReadKey(intercept: true);
            }
        }
 public void Mopayconsoleexplorer()
 {
     IWebDriver driver = new InternetExplorerDriver(@"C:\\net40\");
     driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management");
     new MopayConsol().HomepageTabs(driver);
 }
        public void Test_for_donation_error_text()
        {
            RemoteWebDriver Driver = new InternetExplorerDriver();
            Driver.Navigate().GoToUrl(@"http://en.wikipedia.org/");

            // On Main Page
            var lnkSupportUs = Driver.FindElementByCssSelector(@"a[title='Support us']");
            lnkSupportUs.Click();

            // On Make your donation page

            var radio50UAH = Driver.FindElementByCssSelector(@"#input_amount_0[value='50']");
            radio50UAH.Click();


            // And clich on "Donate" button
            var btnDonate = Driver.FindElementByCssSelector(@"input[value='Donate by credit/debit card']");
            btnDonate.Click();


            // On Billing information

            var txtFirstName = Driver.FindElementByName("fname");
            var txtLastName = Driver.FindElementByName("lname");
            var txtStreet = Driver.FindElementByName("street");
            var txtPostalCode = Driver.FindElementByName("zip");
            var txtCity = Driver.FindElementByName("city");
            var txtEmailAddress = Driver.FindElementByName("emailAdd");

            var radioCardType = Driver.FindElementByCssSelector(@"input[name='cardtype'][value='visa']");


            txtFirstName.Clear();
            txtFirstName.SendKeys("Vasya");

            txtLastName.Clear();
            txtLastName.SendKeys("Poopkin");

            txtCity.Clear();
            txtCity.SendKeys("Kyiv");

            txtEmailAddress.Clear();
            txtEmailAddress.SendKeys("*****@*****.**");

            txtPostalCode.Clear();
            txtPostalCode.SendKeys("80999");

            txtStreet.Clear();
            txtStreet.SendKeys("It is very boring");

            radioCardType.Click();


            // Donation form second part

            var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30));

            string frameSelector = @"div#payment > iframe";

            wait.Until(ExpectedConditions.ElementExists(By.CssSelector(frameSelector)));

            var frameFormSecondPart = Driver.FindElementByCssSelector(frameSelector);

            Driver.SwitchTo().Frame(frameFormSecondPart);

            string cardNumSelector = @"CREDITCARDNUMBER";
            wait.Until(ExpectedConditions.ElementIsVisible(By.Name(cardNumSelector)));

            var txtCreditCardNum = Driver.FindElementByName(cardNumSelector);
            var selectExpMonth = new SelectElement(Driver.FindElementByName(@"EXPIRYDATE_MM"));
            var selectExpYear = new SelectElement(Driver.FindElementByName(@"EXPIRYDATE_YY"));
            var txtCVV = Driver.FindElementByName(@"CVV");
            var btnSubmit = Driver.FindElementById(@"btnSubmit");

            txtCreditCardNum.Clear();
            txtCreditCardNum.SendKeys("4716699955349929");

            selectExpMonth.SelectByText("02");
            selectExpYear.SelectByText("15");

            txtCVV.Clear();
            txtCVV.SendKeys("555");

            // Looks like we cannot click on this button. 
            // Well... 
            btnSubmit.SendKeys(Keys.Enter);

            Driver.SwitchTo().DefaultContent();

            // On Donate result page

            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(@"div#mw-content-text * big > span")));
            var lblTransactionErrorMessage = Driver.FindElement(By.CssSelector(@"div#mw-content-text * big > span"));

            Assert.AreEqual("Your transaction could not be accepted.", lblTransactionErrorMessage.Text);

            Driver.Dispose();

        }
        public void TestBookSearch()
        {
            //First step is browse to website and go to search page.
            System.IO.File.WriteAllText("result.txt","");
            driver = new InternetExplorerDriver();
            driver.Manage().Window.Maximize();
            driver.Navigate().GoToUrl("paratabplus.cloudapp.net");
            driver.FindElementByClassName("menulist").FindElement(By.CssSelector("li a[href=\"/BookSearch/\"]")).Click();
            Assert.AreEqual("Search", driver.Title);
            IWebElement form;
            //-----------------------------------
            /* Next step is find book from define keywords then submit
             * measure time from result that display in grey character on find result(if search result is found.)
             * record it and use these measure data to summarize.
             */
            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("COM-FL2-2812");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Call no:COM-FL2-2812");

            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("Computer");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Bookname:Computer");

            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("James");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Author:James");

            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("shogakukan");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Publisher:shogakukan");

            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("1995");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Year:1995");

            //-----------------------------------
            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("NOV");
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("Sword Art Online Aincrad");
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").SendKeys("Reki Kawahara");
            driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").SendKeys("Zenshu");
            driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
            AssertSearchResult("\r\nCall no:NOV\r\nBookname:Sword Art Online Aincrad\r\nAuthor:Reki Kawahara\r\n" +
                "Publisher:Zenshu\r\nYear:null");

            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").Clear();
            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("PE-FL1-0005");
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("Football training");
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").SendKeys("Graham Taylor");
            driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").SendKeys("Leopard Books");
            driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").SendKeys("1995");
            driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
            AssertSearchResult("\r\nCall no:PE-FL1-0005\r\nBookname:Football training\r\nAuthor:Graham Taylor\r\n" +
                "Publisher:Leopard Books\r\nYear:1995");

            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").Clear();
            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("MAT");
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("Theory of computation");
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").SendKeys("รศ.ดร.เกียรติกูล เจียรนัยธนะกิจ");
            driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").SendKeys("2009");
            driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
            AssertSearchResult("\r\nCall no:MAT\r\nBookname:Theory of computation\r\nAuthor:รศ.ดร.เกียรติกูล เจียรนัยธนะกิจ\r\n" +
                "Publisher:null\r\nYear:2009");

            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").Clear();
            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("NOV");
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("นิทาน");
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").Clear();
            driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
            AssertSearchResult("\r\nCall no:NOV\r\nBookname:นิทาน\r\nAuthor:null\r\n" +
                "Publisher:null\r\nYear:null");
        }
 public virtual void InitializeTest() {
     br = new InternetExplorerDriver();
     wait = new SafeWebDriverWait(br, DefaultTimeOut);
     br.Navigate().GoToUrl(url);
 }
        public void Donate_error_test()
        {
            RemoteWebDriver driver = new InternetExplorerDriver();
            // Navigate to the base url.
            driver.Navigate().GoToUrl(@"http://en.wikipedia.org");

            // Main Page
            var lnkDonate = driver.FindElementByCssSelector(@"a[title='Support us']");
            lnkDonate.Click();

            // Donate Page
            var rbtnDonate50 = driver.FindElementByCssSelector(@"input[name='amount'][value='50']");
            rbtnDonate50.Click();

            var btnMakeDonation = driver.FindElementByCssSelector(@"input[value='Donate by credit/debit card']");
            btnMakeDonation.Click();

            // Donation Payments
            var txtFirstName = driver.FindElementByName("fname");
            var txtLastName = driver.FindElementByName("lname");
            var txtStreet = driver.FindElementByName("street");
            var txtPostalCode = driver.FindElementByName("zip");
            var txtCity = driver.FindElementByName("city");
            var txtEmailAddress = driver.FindElementByName("emailAdd");
            var rbtnCardVisa = driver.FindElementByCssSelector(@"input[name='cardtype'][value='visa']");


            txtFirstName.Clear();
            txtFirstName.SendKeys("Vasya");

            txtLastName.Clear();
            txtLastName.SendKeys("Pupkin");

            txtStreet.Clear();
            txtStreet.SendKeys("Blah blah blah street");

            txtPostalCode.Clear();
            txtPostalCode.SendKeys("8577");

            txtCity.Clear();
            txtCity.SendKeys("My Str");

            txtEmailAddress.Clear();
            txtEmailAddress.SendKeys("*****@*****.**");

            rbtnCardVisa.Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

            
            var frameCardNumber=wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(@"iframe[src^='https://na.gcsip.com/orb/']")));

            driver.SwitchTo().Frame(frameCardNumber);

            var txtName = wait.Until(ExpectedConditions.ElementIsVisible(By.Name("CREDITCARDNUMBER")));

            txtName.Clear();
            txtName.SendKeys("4556767453966453");

            var ddlMonthSelect = new SelectElement(driver.FindElementByName(@"EXPIRYDATE_MM"));
            var ddlYearSelect = new SelectElement(driver.FindElementByName(@"EXPIRYDATE_YY"));
            var txtSecurityCode = driver.FindElementByName(@"CVV");
            var btnContinue = driver.FindElementById("btnSubmit");

            ddlMonthSelect.SelectByText("05");
            ddlYearSelect.SelectByText("15");
            txtSecurityCode.SendKeys("555");

            Assert.IsTrue(btnContinue.Displayed, "There is a Continue button");
            
            btnContinue.SendKeys(Keys.Enter);

            driver.SwitchTo().DefaultContent();

            wait.Until(ExpectedConditions.TitleContains(@"Donate-error - Payments"));

            var lblFirstHeader = driver.FindElementById(@"firstHeading");

            Assert.AreEqual("Donate-error", lblFirstHeader.Text);

        }
        static void Main(string[] args)
        {
            GetUserInfo();

            // Create a new IE driver and navigate to the url
            var ieDriver = new InternetExplorerDriver();
            ieDriver.Navigate().GoToUrl(_listUrl);
            // Wait for the user to log in and go through security concerns
            Console.WriteLine("Please log in to the sharepoint site and wait for it to load, once complete please press enter");
            Console.ReadLine();

            var mainStopwatch = new Stopwatch();
            mainStopwatch.Start();
            Console.WriteLine("Looking at the site");
            // Retreive all of the rows
            var all = ieDriver.FindElements(By.ClassName("ms-itmhover"));

            Console.WriteLine("Found " + all.Count + " applications in " + mainStopwatch.ElapsedMilliseconds + " milliseconds");
            mainStopwatch.Restart();
            // Grab all of the links to the apps
            var allLinks = new string[all.Count];
            var i = 0;
            foreach (IWebElement element in all)
            {
                allLinks[i] = element.FindElement(By.ClassName("ms-vb-title")).FindElement(By.TagName("a")).GetAttribute("href");
                i++;
                Console.WriteLine(i + "/" + all.Count + " Item urls discovered");
            }
            Console.WriteLine("All items urls discovered in " + mainStopwatch.ElapsedMilliseconds + " milliseconds");
            mainStopwatch.Restart();
            GetPageDetails(allLinks, ieDriver, mainStopwatch);
            DownloadObjects();
            SaveToExcel();
            Console.ReadLine();
        }
        public void logging_in_with_valid_credentials_redirects_to_the_dashboard()
        {
            var capabilities = new DesiredCapabilities();
            capabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);

            var driver = new InternetExplorerDriver(capabilities);
            driver.Navigate().GoToUrl(TargetAppUrl + "/Authentication/LogOff");

            try
            {
                driver.Navigate().GoToUrl(TargetAppUrl + "/LogOn");

                driver.FindElement(By.Name("EmailAddress")).SendKeys("*****@*****.**");
                driver.FindElement(By.Name("Password")).SendKeys("TestPassword01");
                driver.FindElement(By.TagName("form")).Submit();

                driver.Url.ShouldEqual(TargetAppUrl + "/");
            }
            finally
            {
                driver.Close();
            }
        }
        public void unauthorized_user_cannot_access_dashboard()
        {
            var capabilities = new DesiredCapabilities();
            capabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);

            var driver = new InternetExplorerDriver(capabilities);
            driver.Navigate().GoToUrl(TargetAppUrl + "/Authentication/LogOff");

            try
            {
                driver.Navigate().GoToUrl(TargetAppUrl + "/Dashboard");

                driver.Url.ShouldEqual(TargetAppUrl + "/LogOn?ReturnUrl=%2fDashboard");
            }
            finally
            {
                driver.Close();
            }
        }
예제 #29
0
        internal static string GetBillAmount(string userName, string password)
        {
            string retVal = "Unavailable";

            //Clean up any previous instances
            Process[] testServerProcesses = Process.GetProcessesByName("IEDriverServer");
            foreach (Process process in testServerProcesses)
            {
                process.Kill();
            }

            Process[] ieProcesses = Process.GetProcessesByName("iexplore");
            foreach (Process process in ieProcesses)
            {
                process.Kill();
            }

            try
            {
                using (IWebDriver driver = new InternetExplorerDriver())
                {
                    driver.Navigate().GoToUrl("https://account.windowsazure.com/Subscriptions");
                    IWebElement usernameTB = null;
                    IWebElement pwTB = null;
                    try
                    {
                        usernameTB = driver.FindElement(By.Id("i0116"));
                    }
                    catch
                    {
                        retVal = "Username input not found.";
                    }
                    if (usernameTB != null)
                    {
                        usernameTB.SendKeys(userName);
                        try
                        {
                            pwTB = driver.FindElement(By.Id("i0118"));
                        }
                        catch
                        {
                            retVal = "Password input not found.";
                        }
                        if (pwTB != null)
                        {
                            pwTB.SendKeys(TickerEncryption.Utility.Decrypt(password, Properties.Settings.Default.Thumb1, Properties.Settings.Default.Thumb2));
                            System.Threading.Thread.Sleep(5000);
                            IWebElement loginBtn = driver.FindElement(By.Id("idSIButton9"));
                            loginBtn.Click();

                            bool loggedInSuccessfully = false;
                            int iterationCount = 1;
                            System.Threading.Thread.Sleep(2000);
                            while (loggedInSuccessfully == false && iterationCount <= 5)
                            {
                                try
                                {
                                    IWebElement subscriptionContent = driver.FindElement(By.Id("subscriptions-list"));
                                    IWebElement firstSubscriptionLink = subscriptionContent.FindElement(By.TagName("a"));
                                    firstSubscriptionLink.Click();
                                    IWebElement charged = driver.FindElement(By.ClassName("subscription-estimated-cost"));
                                    retVal = charged.Text;
                                    loggedInSuccessfully = true;
                                    NetUtil.AddEventLogEntry("BillProvider", "Application", "Account balance populated - " + userName + ".");
                                    System.Threading.Thread.Sleep(2000);
                                    try
                                    {
                                        IWebElement logoutBtn = driver.FindElement(By.Id("header-sign-in"));
                                        logoutBtn.Click();
                                    }
                                    catch
                                    {
                                        NetUtil.AddEventLogEntry("BillProvider", "Application", "Unable to click logout button - " + userName + ".");
                                    }
                                }
                                catch
                                {
                                    //Exception here means login button is still processing, subscription info not loaded.  Try clicking login button again.

                                    loginBtn.Click();
                                    System.Threading.Thread.Sleep(2000);
                                    IWebElement subscriptionContent = driver.FindElement(By.Id("subscriptions-list"));
                                    IWebElement firstSubscriptionLink = subscriptionContent.FindElement(By.TagName("a"));
                                    firstSubscriptionLink.Click();
                                    IWebElement charged = driver.FindElement(By.ClassName("subscription-estimated-cost"));
                                    retVal = charged.Text;
                                    loggedInSuccessfully = true;
                                    NetUtil.AddEventLogEntry("BillProvider", "Application", "Account balance populated - " + userName + ".");
                                    try
                                    {
                                        IWebElement logoutBtn = driver.FindElement(By.Id("header-sign-in"));
                                        logoutBtn.Click();
                                    }
                                    catch
                                    {
                                        NetUtil.AddEventLogEntry("BillProvider", "Application", "Unable to click logout button - " + userName + ".");
                                    }

                                }

                                iterationCount++;
                            }
                            if (!loggedInSuccessfully)
                            {
                                retVal = "Error loading subscription information.";
                                NetUtil.AddEventLogEntry("BillProvider", "Application", "Error loading subscription balance after retry - " + userName + ".");
                            }

                        }

                    }
                    driver.Quit();
                }
            }
            catch(Exception ex)
            {
                NetUtil.AddEventLogEntry("BillProvider", "Application", "Unable start IE driver: " + ex.Message);
            }

            return retVal;
        }
예제 #30
0
 public virtual void InitializeTest() {
     br = new InternetExplorerDriver();
     br.Navigate().GoToUrl(url);
 }
        public void TestMethod1()
        {
            //RemoteWebDriver Driver = new InternetExplorerDriver();
            RemoteWebDriver Driver = new InternetExplorerDriver();
            //Driver.Url = "www.football.ua";
            Driver.Navigate().GoToUrl(@"http://en.wikipedia.org/");
            //Driver.Manage().Window.Maximize();

            var lnkSupportUs = Driver.FindElementByCssSelector(@"a[title = 'Support us']");
            lnkSupportUs.Click();

            // Cannot find with this locator!
            var radio50UAH = Driver.FindElementByXPath("/html/body/div[3]/div[2]/div[3]/table/tbody/tr/td[2]/form/div/div[3]/table/tbody/tr[1]/td[1]/label");//Driver.FindElementById("input_amount_0");// Driver.FindElementByCssSelector(@"#input_amount_0[value='50']");
            radio50UAH.Click();

            var btnDonate = Driver.FindElement(By.ClassName("payment-method-button"));
            btnDonate.Click();

            var txtFirstName = Driver.FindElementById("fname");
            var txtlastName = Driver.FindElementById("lname");
            var txtEmail = Driver.FindElementById("emailAdd");
            var radioCardType = Driver.FindElementById("cc-visa");

            txtFirstName.Clear();
            txtFirstName.SendKeys("Vasya");

            txtlastName.Clear();
            txtlastName.SendKeys("Poopkin");

            txtEmail.Clear();
            txtEmail.SendKeys("*****@*****.**");

            radioCardType.Click();

            var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(6));

            var txtCreditCardNum = Driver.FindElementByName("CREDITCARDNU");
            var selectExpMonth = new SelectElement(Driver.FindElementById("F1010_MM"));
            var selectExpYear = new SelectElement(Driver.FindElementById("F1010_YY"));
            var txtCVV = Driver.FindElementById(@"F1136");
            var btnSubmit = Driver.FindElementById(@"btnSubmit");

            txtCreditCardNum.Clear();
            txtCreditCardNum.SendKeys("8975397698238467");

            selectExpMonth.SelectByText("02");
            selectExpYear.SelectByText("15");

            txtCVV.Clear();
            txtCVV.SendKeys("836");

            btnSubmit.SendKeys(Keys.Enter);

            Driver.SwitchTo().DefaultContent();

            // On Donate results page

            string headerSelector = @"h1.firstHeading";
            var headingElement = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(headerSelector)));

            Assert.AreEqual("Donate-error", headingElement.Text);

            Driver.Quit();
            Driver.Dispose();
        }
예제 #32
0
 /// <summary>
 /// Возвращает драйвер браузера с настройками прокси на актуальный сервер
 /// </summary>
 /// <returns></returns>
 public IWebDriver GetDriver(bool useProxy)
 {
     IWebDriver driver = null;
     if (useProxy)
     {
         Random r = new Random(DateTime.Now.Millisecond);
         bool workedProxyIsFound = false;
         //выбираем случайный прокси из списка адресов в конфиге до тех пор, пока не найдем рабочий
         do
         {
             int proxyIndex = r.Next(document["settings"]["proxies"].ChildNodes.Count);
             string PROXY = document["settings"]["proxies"].ChildNodes[proxyIndex].Attributes[0].Value;
             Proxy proxy = new Proxy();
             proxy.HttpProxy = PROXY;
             proxy.FtpProxy = PROXY;
             proxy.SslProxy = PROXY;
             switch (document["settings"]["driver"].GetAttribute("name"))
             {
                 case "GoogleChrome":
                     ChromeOptions chromeOptions = new ChromeOptions();
                     chromeOptions.Proxy = proxy;
                     driver = new ChromeDriver(document["settings"]["driver"].GetAttribute("path"), chromeOptions, TimeSpan.FromSeconds(300));
                     break;
                 case "Firefox":
                     FirefoxProfile profile = new FirefoxProfile();
                     profile.SetProxyPreferences(proxy);
                     driver = new FirefoxDriver(new FirefoxBinary(), profile, TimeSpan.FromSeconds(300));
                     break;
                 case "Opera":
                     OperaOptions operaOptions = new OperaOptions();
                     operaOptions.Proxy = proxy;
                     driver = new OperaDriver(document["settings"]["driver"].GetAttribute("path"), operaOptions, TimeSpan.FromSeconds(300));
                     break;
                 case "IE":
                     InternetExplorerOptions IEOptions = new InternetExplorerOptions();
                     IEOptions.Proxy = proxy;
                     driver = new InternetExplorerDriver(document["settings"]["driver"].GetAttribute("path"), IEOptions, TimeSpan.FromSeconds(300));
                     break;
             }
             //Проверяем работу прокси обращаясь к гуглу
             driver.Navigate().GoToUrl("http://www.google.ru/");
             Thread.Sleep(10000);
             workedProxyIsFound = driver.Title == "Google";
             if (!workedProxyIsFound)
                 driver.Quit();
         }
         while (!workedProxyIsFound);
     }
     else
     {
         switch (document["settings"]["driver"].GetAttribute("name"))
         {
             case "GoogleChrome":
                 driver = new ChromeDriver(document["settings"]["driver"].GetAttribute("path"));
                 break;
             case "Firefox":
                 driver = new FirefoxDriver(new FirefoxBinary(), new FirefoxProfile(), TimeSpan.FromSeconds(120));
                 break;
             case "Opera":
                 driver = new OperaDriver(document["settings"]["driver"].GetAttribute("path"));
                 break;
             case "IE":
                 driver = new InternetExplorerDriver(document["settings"]["driver"].GetAttribute("path"));
                 break;
         }
     }
     return driver;
 }
        public void Softuni_OpenSoftUniWebsite_ShouldPassTest()
        {
            using (IWebDriver wdriver = new InternetExplorerDriver())
            {
                wdriver.Navigate().GoToUrl("https://softuni.bg/trainings/1175/High-Quality-Code-July-2015");
                wdriver.FindElement(By.TagName("body")).Click();
                string actualLinkText = wdriver.FindElement(By.LinkText("Предишни инстанции на курса")).Text;

                wdriver.Quit();
            }
        }
예제 #34
0
 public void IETest()
 {
     var driver =
         new InternetExplorerDriver(@"C:\Users\liu\Documents\Visual Studio 2012\Projects\TestProject\TestProject");
     driver.Navigate().GoToUrl("http://www.baidu.com");
 }