public static void DragAndDrop(this IWebDriverExt driver, IWebElement source, IWebElement destination)
 {
     (new Actions(driver))
     .DragAndDrop(source, destination)
     .Build()
     .Perform();
 }
예제 #2
0
        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 { }
        }
예제 #4
0
        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);
 }
예제 #7
0
 public static bool isAlertPresent(this IWebDriverExt driver)
 {
     try
     {
         driver.SwitchTo().Alert();
         return(true);
     }
     catch (NoAlertPresentException)
     {
         return(false);
     }
 }
예제 #8
0
        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);
        }
예제 #11
0
        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("~");
            }
        }
예제 #12
0
 /// <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);
     }
 }
예제 #13
0
        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);
                }
            }
        }
예제 #14
0
        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);
        }
예제 #16
0
 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));
        }
예제 #20
0
 public static WebElement GetElement(this IWebDriverExt driver)
 {
     return(new WebElement());
 }
예제 #21
0
        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
        }