public static void DragAndDrop(this IWebDriverExt driver, IWebElement source, IWebElement destination) { (new Actions(driver)) .DragAndDrop(source, destination) .Build() .Perform(); }
public static List <WebElement> GetSubNodes(IWebDriverExt driver) { List <WebElement> list = new List <WebElement>(); /// /// return(list); }
public static void WaitStaticDOM(this IWebDriverExt driver) { Func <bool> ready = () => driver.ExecuteJavaScript("return document.readyState").Equals("complete"); try { WaitHelper.SpinWait(ready, TimeSpan.FromSeconds(10), driver.WaitProfile.PollingInterval); } catch { } }
public static void TryExpandTreeFolder(this IWebDriverExt driver, string folderName) { string collapsed = @".//span[@class='rtPlus']"; WebElement currentFolder = driver.FindTreeItemByName(folderName); WebElement parentElement = currentFolder.GetParent(); WaitHelper.Try(() => parentElement.FindRelative().ByXPath(collapsed).Click()); }
public static void Highlight(this IWebDriverExt driver, IWebElement iWebElement, int ms = 100) { try { var originalElementBorder = (string)driver.ExecuteJavaScript("return arguments[0].style.border", iWebElement); driver.ExecuteJavaScript("arguments[0].style.border='3px solid red'; return;", iWebElement); Thread.Sleep(ms); driver.ExecuteJavaScript("arguments[0].style.border='" + originalElementBorder + "'; return;", iWebElement); } catch (Exception) { } }
public static IWebDriverExt AcceptAlert(this IWebDriverExt driver) { try { driver.SwitchTo().Alert().Accept(); driver.SwitchTo().ActiveElement(); } catch (NoAlertPresentException) { } return(driver); }
public static bool isAlertPresent(this IWebDriverExt driver) { try { driver.SwitchTo().Alert(); return(true); } catch (NoAlertPresentException) { return(false); } }
public static IWebDriverExt SwitchToDefaultContent(this IWebDriverExt driver) { driver.WaitReadyState(); driver.SwitchTo().DefaultContent(); driver.CurrentFrame = By.Id(Locators.MainHeadPage.FrameLocatorID); driver.WaitReadyState(); return(driver); }
public static IWebDriverExt Shutdown(this IWebDriverExt driver) { if (driver == null) { return(driver); } Thread.Sleep(1000); driver.Quit(); driver.Dispose(); driver = null; return(driver); }
public static IWebDriverExt SwitchToFrame(this IWebDriverExt driver, By by) { driver.WaitReadyState(); if (driver.TryFindElement(by)) { IWebElement frame = driver.FindElement(by); driver.SwitchTo().Frame(frame); driver.CurrentFrame = by; driver.WaitReadyState(); } return(driver); }
public static void SendStringToWinDialog(this IWebDriverExt driver, string stringToSend) { if (Object.ReferenceEquals(driver.GetType(), typeof(FirefoxDriverExt))) { SendStringToOpenFileDialogUsingWhite(driver, stringToSend); return; } lock (locker) { WaitHelper.Wait(500); System.Windows.Forms.SendKeys.SendWait(stringToSend); System.Windows.Forms.SendKeys.SendWait("~"); } }
/// <summary> /// Returns name of a selected folder within tree /// </summary> /// <param name="driver"></param> /// <returns></returns> public static string FindSelectedFolder(this IWebDriverExt driver) { try { //return new WebElement().ByXPath(Locators.TestPlanPage.selectedFolderXPath).NodeName; return(new WebElement() .ByClass(Locators.TestPlanPage.selectedItemAttributeValue, false) .FindRelative().ByTagName(WEBUIautomation.Tags.TagNames.Span) .ByClass("rtIn") .Text); } catch { return(string.Empty); } }
public static void Initialize(Browsers browser) { lock (Instancelocker) { instance = instance.Shutdown(); WebDriverFactory factory = new WebDriverFactory(); instance = factory.Create(browser); if (browser == Browsers.ie) { instance.Shutdown(); instance = factory.Create(browser); } } }
private static void SendStringToOpenFileDialogUsingWhite(IWebDriverExt driver, string stringToSend) { try { var app = TestStack.White.Application.Attach((driver as FirefoxDriverExt).PID); var windows = app.GetWindows(); var openFileDialog = windows[1]; TextBox fileNameField = openFileDialog.Get <TextBox>(SearchCriteria.ByAutomationId("1148")); fileNameField.Text = stringToSend; Button openButton = openFileDialog.Get <Button>(SearchCriteria.ByAutomationId("1")); openButton.Click(); } catch { } }
public static string GetNewWindow(this IWebDriverExt driver) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); string window = wait.Until <string> (d => { if (driver.WindowHandles.Count < 2) { return(null); } return(driver.WindowHandles[1]); } ); return(window); }
public static WebElement GetRootNode(IWebDriverExt driver) { return(driver.GetElement() .ByTagName(WEBUIautomation.Tags.TagNames.Li) .ByClass(ContentLocators.Locators.TreeHelperLocators.rootFolderClassValue)); }
public static void BrowserMaximize(this IWebDriverExt driver) { driver.Manage().Window.Maximize(); }
public static void SetBrowserResolution(this IWebDriverExt driver, int width, int height) { driver.Manage().Window.Position = new Point(0, 0); driver.Manage().Window.Size = new Size(width, height); }
public static object ExecuteJavaScript(this IWebDriverExt driver, string javaScript, params object[] args) { var javaScriptExecutor = (IJavaScriptExecutor)driver; return(javaScriptExecutor.ExecuteScript(javaScript, args)); }
public static WebElement GetElement(this IWebDriverExt driver) { return(new WebElement()); }
public static WebElement FindTreeItemByName(this IWebDriverExt driver, string text) { string xPathItemLocator = string.Format(".//li/div/span[@class='rtIn'][text()='{0}']", text); return(driver.GetElement().ByXPath(xPathItemLocator).ReturnFound()); }
public static void WaitReadyState(this IWebDriverExt driver) { driver.WaitStaticDOM(); /// A wait for angular has to be here }