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(); }
public void TestIE() { driver = new InternetExplorerDriver(); //OpenPage needs to run twice because of an initialization bug with the IE driver OpenPage<GoogleHomePage>("http://www.google.com/"); OpenPage<GoogleHomePage>("http://www.google.com/"); driver.Quit(); }
public void ShouldBeAbleToCallQuitConsecutively() { driver.Url = simpleTestPage; driver.Quit(); driver.Quit(); driver = new InternetExplorerDriver(); driver.Url = xhtmlTestPage; driver.Quit(); }
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(); }
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 ShouldBeAbleToStartMoreThanOneInstanceOfTheIEDriverSimultaneously() { IWebDriver secondDriver = new InternetExplorerDriver(); driver.Url = xhtmlTestPage; secondDriver.Url = formsPage; Assert.AreEqual("XHTML Test Page", driver.Title); Assert.AreEqual("We Leave From Here", secondDriver.Title); // We only need to quit the second driver if the test passes secondDriver.Quit(); }
public void ShouldBeAbleToCallDisposeAfterQuit() { EnvironmentManager.Instance.CloseCurrentDriver(); IWebDriver testDriver = new InternetExplorerDriver(); testDriver.Url = simpleTestPage; testDriver.Quit(); testDriver.Dispose(); testDriver = new InternetExplorerDriver(); testDriver.Url = xhtmlTestPage; Assert.AreEqual("XHTML Test Page", testDriver.Title); testDriver.Quit(); }
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(); }
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(); }
static void Main(string[] args) { NavigationData data = new NavigationData(); MenuFilterSection menu = MenuFilterSection.GetConfig(); List<string> ids = menu.GetItemsToBeRemove(); string filter = string.Join(",", ids.ToArray()); MenuOrderSection menuOrder = MenuOrderSection.GetConfig(); List<SAMenuItemDTO> menuItems = data.GetAllUsedDiagrams(filter); List<string> errorUrls = new List<string>(); foreach (var item in menuItems) { foreach (var item2 in item.ChildItems) { InternetExplorerDriver driver = new InternetExplorerDriver(); string url = string.Format("http://wpsa1/tobe_ea/Default.aspx?id={0}", item2.Key); driver.Url = url; var sc = driver.GetScreenshot(); sc.SaveAsFile(item2.Key.ToString() + ".jpg", ImageFormat.Jpeg); //Thread.Sleep(100000); var x = driver.FindElementById("reportId"); if (x == null) { errorUrls.Add(url); } driver.Quit(); } } File.WriteAllLines(@"BrokenPages.txt", errorUrls.ToArray()); Console.ReadLine(); }
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 TestIE() { driver = new InternetExplorerDriver(); OpenPage<GoogleHomePage>("http://www.google.com/"); driver.Quit(); }
[TestMethod, Ignore] // failing for unknown reason - investigate later public void RunIeQUnitTests() { using (var ie = new InternetExplorerDriver()) { RunQUnitTests(ie, "ie"); ie.Quit(); } }
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(); }
public void EdgeDriverCleanup() { _driver.Quit(); }
static void Main(string[] args) { // Application Start Console.WriteLine("ATC-SIM AI By Cory Gehr (2015)\n"); if (args.Length == 5) { // Setup for the ATC-SIM Environment Console.WriteLine("Starting Selenium Server...\n"); IWebDriver driver; switch (args[0]) { default: case "ie": // Prepare IE settings InternetExplorerOptions ieOptions = new InternetExplorerOptions { IgnoreZoomLevel = true, InitialBrowserUrl = "http://atc-sim.com/", PageLoadStrategy = InternetExplorerPageLoadStrategy.Eager // Wait for pages to be 'complete' }; // Create a new instance of the IE WebDriver driver = new InternetExplorerDriver(ieOptions); break; } // Wait for the page to load WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); wait.Until((d) => { try { return (d.FindElement(By.Id("frmOptions")) != null); } catch (NoSuchElementException) { // Do nothing, keep waiting return false; } }); // // CONFIGURE SIMULATOR // try { /// AIRPORT // Change the value of the airport selector UIHelper.ChangeDropDownByValue(ref driver, "selAirport", args[1]); /// IATA Preference if (Boolean.Parse(args[2])) { UIHelper.ChangeRadioByValue(ref driver, "rdoICAOorIATA", "IATA"); } /// WIND DIRECTION // Get element for wind direction UIHelper.ChangeDropDownByValue(ref driver, "WindChance", args[3]); // REALISM string playMoveValue; switch (args[4]) { case "easy": playMoveValue = "1"; break; case "arrivals": playMoveValue = "2"; break; case "departures": playMoveValue = "3"; break; default: playMoveValue = "0"; break; } UIHelper.ChangeDropDownByValue(ref driver, "PlayMode", playMoveValue); /// SCALE MARKERS /// We change this automatically, no option provided to end-user UIHelper.ChangeDropDownByValue(ref driver, "ScaleMarks", "2"); // Submit form Console.WriteLine("\nSubmitting settings form..."); UIHelper.SubmitForm(ref driver, "frmOptions"); Console.WriteLine("Loading radar scope..."); // Wait for the new page to load wait.Until((d) => { try { return (d.FindElement(By.Name("frmClearance")) != null); } catch (NoSuchElementException) { // Do nothing, keep waiting return false; } }); } catch (NoSuchElementException ex) { Console.Error.WriteLine("FATAL: One or more required form elements could not be found. Cannot proceed."); Console.Error.WriteLine("Additional information: " + ex.Message + "\n"); return; } catch (Exception ex) { Console.Error.WriteLine("FATAL: A general exception has occurred. Cannot continue."); Console.Error.WriteLine("Additional information: " + ex.Message + "\n"); return; } // Start controller Controller controller = new Controller(driver); controller.Run(); // One Run() has finished, exit driver.Quit(); Console.WriteLine("\n--Disconnected--"); } else { // Output usage options Console.WriteLine("Usage:\n\tAIRPORT AIRLINEIATAOPT WIND REALISM\n\t(All arguments required)"); Console.WriteLine("Arguments:"); Console.WriteLine("\tAIRPORT - ICAO Code for Target Airport (See website for list)"); Console.WriteLine("\tAIRLINEIATAOPT - Use IATA Codes for Airlines (True or False)"); Console.WriteLine("\tWIND - Wind Change Frequency (0, 10, 25, 50, 75, 100)"); Console.WriteLine("\tREALISM - Realism Settings (normal, easy, arrivals, departures)"); return; } }
/// <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(); } }
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; }