public void LazyElementExistsNow() { LazyElement slowLoad = new LazyElement(this.TestObject, By.CssSelector("#AsyncContent[style*='block']")); WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase() + "Automation/AsyncPage"); Assert.IsFalse(slowLoad.ExistsNow, "Element should not exist yet"); }
public void LazyElementSubmit() { WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase() + "Employees"); WebDriver.Wait().ForClickableElement(By.CssSelector("A[href^='/Employees/Edit/']")).Click(); WebDriver.Wait().ForPageLoad(); this.SubmitButton.Submit(); Assert.IsTrue(WebDriver.Wait().UntilAbsentElement(By.CssSelector("#[type='submit']")), "Submit did not go away"); }
public void LazyElementFindElementsRespectAction() { IWebElement firstElement = this.DivRoot.FindElements(this.DisabledItem.By)[0]; this.WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase()); this.WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase() + "Automation"); this.WebDriver.SetWaitDriver(new OpenQA.Selenium.Support.UI.WebDriverWait(this.WebDriver, TimeSpan.FromSeconds(1))); firstElement.Click(); }
public void GetWebsiteBase() { #region GetWebsiteBase string website = SeleniumConfig.GetWebSiteBase(); #endregion GetWebsiteBase Assert.IsTrue(website.Equals("http://magenicautomation.azurewebsites.net/", StringComparison.InvariantCultureIgnoreCase)); }
public void LazyElementFindElementsStackedWithStale() { LazyElement lazyRoot = new LazyElement(this.TestObject, By.CssSelector("#ItemsToAutomate")); IWebElement secondTable = lazyRoot.FindElements(By.CssSelector("TABLE"))[1]; IWebElement lastTableHeader = ((LazyElement)secondTable).FindElements(By.CssSelector("THEAD TH"))[4]; this.WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase()); this.WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase() + "Automation"); Assert.AreEqual("Color", lastTableHeader.Text); }
public void SeparateInteractions() { SeleniumDriverManager newDriver = new SeleniumDriverManager(() => WebDriverFactory.GetBrowserWithDefaultConfiguration(BrowserType.HeadlessChrome), this.TestObject); newDriver.GetWebDriver().Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase()); this.ManagerStore.Add("test", newDriver); this.TestObject.WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase() + "/Automation"); Assert.AreNotEqual(this.TestObject.WebDriver.Url, this.ManagerStore.GetManager <SeleniumDriverManager>("test").GetWebDriver().Url); }
public void WebDriverUsesProxy() { DriverOptions options = WebDriverFactory.GetDefaultHeadlessChromeOptions(); options.SetProxySettings(Config.GetValueForSection(ConfigSection.SeleniumMaqs, "ProxyAddress")); this.WebDriver = WebDriverFactory.GetChromeDriver(TimeSpan.FromMilliseconds(61000), (ChromeOptions)options); string url = Path.Combine(SeleniumConfig.GetWebSiteBase().Replace("https://", "http://"), "Employees"); this.WebDriver.Navigate().GoToUrl(url); bool proxyUsed = RequestsHistory.Values.Any(r => r.RequestUri.ToString().Contains("magenicautomation.azurewebsites.net/Employees")); Assert.IsTrue(proxyUsed, "Failed to assert the proxy was used by the web driver."); }
public void LazyCaching() { // Create the lazy element and use it LazyElement footer = new LazyElement(this.TestObject, By.CssSelector("FOOTER P"), "Footer"); // Trigger a find and save off the element footer.GetValue(); IWebElement footerElementBefore = footer.CachedElement; // Do the event again and save off the changed element footer.GetValue(); // Go to another page so the old element will be stale, this will force us to get a new one WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase() + "Automation/AsyncPage"); // Trigger a new find, this should be new because the cached element is stale footer.GetValue(); Assert.AreNotEqual(footerElementBefore, footer.CachedElement); }
public void NavigateToTestPage() { this.WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase() + "Automation"); this.WebDriver.Wait().ForPageLoad(); }
public void CreateSeleniumPageModel() { this.WebDriver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase() + "Automation"); this.WebDriver.Wait().ForPageLoad(); this.basePageModel = new SeleniumPageModel(this.TestObject); }
/// <summary> /// Make sure the page gets reloaded /// </summary> /// <param name="driver">Current test web driver</param> private static void LeaveAndReturnToPage(IWebDriver driver) { driver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase()); driver.Navigate().GoToUrl(SeleniumConfig.GetWebSiteBase() + "Automation"); driver.Wait().ForPageLoad(); }