//[SetUp] public void SetupTest(IWebDriver driverp) { //driver = new ChromeDriver(); //TODO: We can iterate drivers driver = driverp; //TODO: We can read the server from config file or table baseURL = "http://ebgdev03:81"; verificationErrors = new StringBuilder(); wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(timeout)); //Logs directories if (!System.IO.Directory.Exists(imageLogsDirectory)) System.IO.Directory.CreateDirectory(imageLogsDirectory); }
public static void waitForPage(IWait <IWebDriver> wait, string url) { wait.Until(d => d.Url == url); waitForPage(wait); }
protected InvalidWaitException(string message, IWait wait) : base(message) { SetField.NotNull(out this.wait, nameof(wait), wait); }
public InvalidTypeException(IWait wait, Type type) : base($"invalid type: expected {wait.ItemType}, have {type.Name}", wait) { SetField.NotNull(out this.type, nameof(type), type); }
public InvalidNextException(IWait wait) : base($"invalid next: {wait}", wait) { }
public ProductPage(IWebDriver driver) { this.driver = driver; wait = new WebDriverWait(this.driver, TimeSpan.FromSeconds(10)); }
public Objects(IWebDriver driver, BrowserInit browser) { this.driver = driver; this.iWait = browser.iWait; }
/// <summary> /// Waits for the page to be completely loaded /// </summary> /// <param name="waitForComplete">The wait for complete.</param> public void WaitForComplete(IWait waitForComplete) { waitForComplete.DoWait(); }
public TicketRetriever(IWait wait, IZendeskApi zendeskApi, Func<DateTime> utcNowProvider = null) { _wait = wait; _zendeskApi = zendeskApi; _utcNowProvider = utcNowProvider ?? (() => DateTime.UtcNow); }
public override string ToString() { IWait wait = this; return($"Wait: {wait.Need} {wait.NeedType?.Name} for {this.rest?.Target.GetType().Name}.{this.rest?.Method.Name} have {wait.ItemType?.Name} {this.item}"); }
void IDialogStack.Fail(Exception error) { this.wait = this.fiber.Fail(error); }
public Chrome_BuyVideoVerification(IWebDriver driver, ILog log1, IJavaScriptExecutor Executor, IWait <IWebDriver> iWait) { this.driver = driver; log = log1; this.executor = Executor; this.iWait = iWait; }
public WebDriver(LoggerClass log) { Driver = new ChromeDriver(); _wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(_waitTimeout)); _log = log; }
public Chrome_QAManagement(IWebDriver driver, ILog log1, IJavaScriptExecutor Executor, IWait <IWebDriver> iWait) { this.driver = driver; log = log1; this.executor = Executor; this.iWait = iWait; }
public static IWait <C> CloneTyped <C>(this IWait <C> wait) { return((IWait <C>)wait.Clone()); }
public BrowserInit() { try { string rootPath = AppDomain.CurrentDomain.BaseDirectory; //string rootPath = Environment.CurrentDirectory; //string rootPath = @"D:\workspace\FTC\FTC\FTC.Framework\bin\Debug"; //System.Environment.SetEnvironmentVariable(driverName, driverPath); if (Convert.ToBoolean(browser.SelectBrowser(BrowserCollection.firefox.ToString(), "Browser.xml")) == true) { driver = new FirefoxDriver(); Current.BrowserName = BrowserCollection.firefox.ToString(); screenHeight = Helper.GetScreenHeight(driver); screenWidth = Helper.GetScreenWidth(driver); Helper.SetWindowPosition(driver, 0, 0); Helper.SetWindowSize(driver, screenWidth, screenHeight); } else if (Convert.ToBoolean(browser.SelectBrowser(BrowserCollection.chrome.ToString(), "Browser.xml")) == true) { driverName = "webdriver.chrome.driver"; // driverPath = rootPath + "\\chromedriver.exe"; System.Environment.SetEnvironmentVariable(driverName, driverPath); // driverPath = rootPath+"\\Library\\"; // driverName = "webdriver.chrome.driver"; ChromeOptions options = new ChromeOptions(); //options.AddArgument("--disable-extensions"); driver = new ChromeDriver(rootPath, options); Current.BrowserName = BrowserCollection.chrome.ToString(); screenHeight = Helper.GetScreenHeight(driver); screenWidth = Helper.GetScreenWidth(driver); Helper.SetWindowPosition(driver, 0, 0); Helper.SetWindowSize(driver, screenWidth, screenHeight); Console.WriteLine("Is Driver null :: " + (driver == null)); } else if (Convert.ToBoolean(browser.SelectBrowser(BrowserCollection.ie.ToString(), "Browser.xml")) == true) { InternetExplorerOptions options = new InternetExplorerOptions(); options.EnsureCleanSession = true; options.EnableNativeEvents = true; options.IgnoreZoomLevel = true; options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; driverName = "webdriver.ie.driver"; driverPath = rootPath + "/IEDriverServer.exe"; driver = new InternetExplorerDriver(options); screenHeight = Helper.GetScreenHeight(driver); screenWidth = Helper.GetScreenWidth(driver); Helper.SetWindowPosition(driver, 0, 0); Helper.SetWindowSize(driver, screenWidth, screenHeight); Current.BrowserName = BrowserCollection.ie.ToString(); // Add code to add Registry in IE 11 Current.IEVersion = Helper.GetIEVersion(driver, driver.FindElement(By.TagName("html"))); if (Current.IEVersion.Equals("IE11")) { Helper.CheckIE11RegistryPresence(); } } else if (Convert.ToBoolean(browser.SelectBrowser(BrowserCollection.phantom.ToString(), "Browser.xml")) == true) { driver = new PhantomJSDriver(); Current.BrowserName = BrowserCollection.phantom.ToString(); screenHeight = Helper.GetScreenHeight(driver); screenWidth = Helper.GetScreenWidth(driver); Helper.SetWindowPosition(driver, 0, 0); Helper.SetWindowSize(driver, screenWidth, screenHeight); } else { throw new NoBrowserSelectedException(); } iWait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(150.00)); } catch (NoBrowserSelectedException ex) { Logger.log.Error("Error In Browser Selection."); Logger.log.Error(ex); } catch (Exception ex) { Logger.log.Error("Error In Browser Initialization."); Logger.log.Error(ex); } }
/// <summary> /// Wait until element is actually displayed in the DOM /// </summary> /// <param name="wait"></param> /// <param name="webElement"></param> public static void WaitForWebElementDisplayed(IWait <IWebDriver> wait, IWebElement webElement) { wait.Until(x => webElement.Displayed); }
/// <summary> /// Wait until element is enabled /// </summary> /// <param name="wait"></param> /// <param name="webElement"></param> public static void WaitForWebElementEnabled(IWait <IWebDriver> wait, IWebElement webElement) { wait.Until(x => webElement.Enabled); }
private void Wait_Free(IWait sender) { waits.Where(x => x.Item1.Equals(sender)).FirstOrDefault()?.Item2.Set(); }
public static void waitForPage(IWait <IWebDriver> wait) { wait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete")); }
private static void waitForElement(IWait <IWebDriver> wait, IWebElement parentElement, By elementPath, ElementState status) { switch (status) { case ElementState.VISIBLE: wait.Until(driver => { try { return(parentElement != null ? parentElement.FindElement(elementPath).Displayed : driver.FindElement(elementPath).Displayed); } catch (NoSuchElementException) { return(false); } }); break; case ElementState.NOT_VISIBLE: wait.Until(driver => { try { return(parentElement != null ? !parentElement.FindElement(elementPath).Displayed : !driver.FindElement(elementPath).Displayed); } catch (NoSuchElementException) { return(true); } }); break; case ElementState.EXISTS: wait.Until(driver => { try { var element = parentElement != null ? parentElement.FindElement(elementPath) : driver.FindElement(elementPath); return(true); } catch (NoSuchElementException) { return(false); } }); break; case ElementState.NOT_EXIST: wait.Until(driver => { try { var element = parentElement != null ? parentElement.FindElement(elementPath) : driver.FindElement(elementPath); return(false); } catch (NoSuchElementException) { return(true); } }); break; default: throw new Exception($" '{status}' is not a valid status to wait for element"); } }
/// <summary> /// A wait util method to use when waiting for an element to be in a state /// </summary> /// <param name="wait">The preconfigured driver wait to use</param> /// <param name="parentElement">the parent of the element to wait for</param> /// <param name="elementPath">The OpenQA.Selenium.By used to locate the element</param> /// <param name="status">visible, not visible, exist, not exist</param> /// <returns> a boolean indicating if the expected status is true or false</returns> public static bool elementState(IWait <IWebDriver> wait, IWebElement parentElement, By elementPath, ElementState status) => waitForElementRunner(wait, parentElement, elementPath, status);
public Objects(IWebDriver driver, IWait <IWebDriver> wait) { this.driver = driver; this.wait = wait; }
public InvalidNeedException(IWait wait, Need need) : base($"invalid need: expected {need}, have {wait.Need}", wait) { this.need = need; this.have = wait.Need; }
public BookDetailsPage(IWebDriver driver, IWait <IWebDriver> wait) : base(driver, wait) { }
public WebDriver(string driverType, LoggerClass log) { _log = log; if (ConfigurationManager.AppSettings.Get("Grid") == "true") { DesiredCapabilities capabilities = new DesiredCapabilities(); switch (driverType) { case "Firefox": capabilities = DesiredCapabilities.Firefox(); capabilities.SetCapability(CapabilityType.BrowserName, "firefox"); _log.Log("Start Webdriver grid firefox"); break; case "IE": capabilities = DesiredCapabilities.InternetExplorer(); capabilities.SetCapability(CapabilityType.BrowserName, "internet explorer"); _log.Log("Start Webdriver grid internet explorer"); break; case "Chrome": capabilities = DesiredCapabilities.Chrome(); capabilities.SetCapability(CapabilityType.BrowserName, "chrome"); _log.Log("Start Webdriver grid chrome"); break; default: capabilities = DesiredCapabilities.Chrome(); capabilities.SetCapability(CapabilityType.BrowserName, "chrome"); _log.Log("Start Webdriver grid default chrome"); break; } switch (ConfigurationManager.AppSettings.Get("PlatformType")) { case "Windows": capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows)); _log.Log("Platform grid Windows"); break; case "Linux": capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Linux)); _log.Log("Platform grid Linux"); break; case "Mac": capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Mac)); _log.Log("Platform grid Mac"); break; case "Unix": capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Unix)); _log.Log("Platform grid Unix"); break; case "XP": capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.XP)); _log.Log("Platform grid XP"); break; default: capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows)); _log.Log("Platform grid default Windows"); break; } capabilities.SetCapability("marionette", true); Driver = new RemoteWebDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("localhost") + ":" + ConfigurationManager.AppSettings.Get("port") + "/wd/hub"), capabilities); _log.Log("Grid Server" + "http://" + ConfigurationManager.AppSettings.Get("localhost") + ":" + ConfigurationManager.AppSettings.Get("port") + "/wd/hub"); } else { switch (driverType) { case "Firefox": Driver = new FirefoxDriver(); _log.Log("Start firefox webdriver"); break; case "IE": Driver = new InternetExplorerDriver(); _log.Log("Start internet explorer webdriver"); break; case "Chrome": Driver = new ChromeDriver(); _log.Log("Start Chrome webdriver"); break; default: Driver = new ChromeDriver(); _log.Log("Start default Chrome webdriver"); break; } } _wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(_waitTimeout)); Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); }
public WaitTests() { _log = Mock.Of<ILog>(); _sut = new Wait(_log); }
private void AddTimeouts() { WebDriver.Manage().Window.Maximize(); WebDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(configuration.Timeout); Wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(30.00)); }
/// <summary> /// Wait until element is enabled /// </summary> /// <param name="wait"></param> /// <param name="webElement"></param> public static void WaitForWebElementEnabled(IWait<IWebDriver> wait, IWebElement webElement) { wait.Until(x => webElement.Enabled); }
public HomePage(IWebDriver driver, IWait <IWebDriver> wait) : base(driver, wait) { this.header = new HeaderSection(driver, wait); this.footer = new FooterSection(driver, wait); }
public CustomWebDriver() : base() { this.Wait = new WebDriverWait(this, new TimeSpan(0, 0, 40)); this.Manage().Window.Maximize(); }
public SiteNavigator(IWebDriver webDriver) { _driver = webDriver; _wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(20)); _currentPage = new HomePage(webDriver); }
void IDialogStack.Done <R>(R value) { this.wait = this.fiber.Done(value); }
void IDialogStack.Wait <R>(ResumeAfter <R> resume) { this.wait = this.fiber.Wait <DialogTask, R>(ToRest(resume)); }
/// <summary> /// Wait until element is actually displayed in the DOM /// </summary> /// <param name="wait"></param> /// <param name="webElement"></param> public static void WaitForWebElementDisplayed(IWait<IWebDriver> wait, IWebElement webElement) { wait.Until(x => webElement.Displayed); }
public TicketRetrieverTests() { _wait = Mock.Of<IWait>(); _zendeskApi = Mock.Of<IZendeskApi>(); _utcNowProvider = Mock.Of<Func<DateTime>>(); _sut = new TicketRetriever(_wait, _zendeskApi, _utcNowProvider); SetupDefaultMocks(); }