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 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(); } }
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 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(); } }
public void ShouldBeAbleToCallQuitAfterCallingCloseOnOnlyOpenWindow() { EnvironmentManager.Instance.CloseCurrentDriver(); IWebDriver testDriver = new InternetExplorerDriver(); testDriver.Url = simpleTestPage; testDriver.Close(); testDriver.Quit(); testDriver = new InternetExplorerDriver(); testDriver.Url = xhtmlTestPage; Assert.AreEqual("XHTML Test Page", testDriver.Title); testDriver.Quit(); }
public void ShouldBeAbleToCallQuitAfterCallingCloseOnOnlyOpenWindow() { EnvironmentManager.Instance.CloseCurrentDriver(); IWebDriver testDriver = new InternetExplorerDriver(); testDriver.Url = simpleTestPage; testDriver.Close(); testDriver.Quit(); testDriver = new InternetExplorerDriver(); testDriver.Url = xhtmlTestPage; Assert.AreEqual("XHTML Test Page", testDriver.Title); testDriver.Quit(); }
public void ShouldNotBeAbleToCallDriverMethodAfterCallingCloseOnOnlyOpenWindow() { EnvironmentManager.Instance.CloseCurrentDriver(); IWebDriver testDriver = new InternetExplorerDriver(); try { testDriver.Url = simpleTestPage; testDriver.Close(); string url = testDriver.Url; // Should never reach this line. Assert.AreEqual(string.Empty, url); } catch (WebDriverException) { } finally { testDriver.Dispose(); } }
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(); } }
public void ShouldNotBeAbleToCallDriverMethodAfterCallingCloseOnOnlyOpenWindow() { EnvironmentManager.Instance.CloseCurrentDriver(); IWebDriver testDriver = new InternetExplorerDriver(); try { testDriver.Url = simpleTestPage; testDriver.Close(); string url = testDriver.Url; // Should never reach this line. Assert.AreEqual(string.Empty, url); } catch (WebDriverException) { } finally { testDriver.Dispose(); } }
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(); } }
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(); } }