/// <summary>
 /// Force text into Kendo DropDownCombo input.
 /// </summary>
 /// <param name="ele">IWebElement input</param>
 /// <param name="text">text to input</param>
 private static void ForceTextToListInput(this IWebElement ele, string text)//ToDo: remove sleeps once Netlag is fixed - dg 03/14/17
 {
     WaitHelpers.ExplicitWait(200);
     WaitHelpers.WaitForAjaxLoad();
     WaitHelpers.ExplicitWait(100);
     ele.Click();
     WaitHelpers.ExplicitWait(100);
     ele.Clear();
     WaitHelpers.ExplicitWait(100);
     ele.SendKeys(text);
     WaitHelpers.ExplicitWait(100);
     ele.SendKeys(Keys.Tab);
     WaitHelpers.ExplicitWait(100);
 }
        public static DataSet GetData(string query, string connectionString = "")
        {
            if (String.IsNullOrEmpty(connectionString))
            {
                connectionString = ConnectionString;
            }

            var retData    = new DataSet();
            var connection = new SqlConnection(connectionString);

            using (connection)
            {
                WaitHelpers.ExplicitWait();
                var adapter = new SqlDataAdapter(query, connection);
                adapter.Fill(retData);
            }

            return(retData);
        }
예제 #3
0
        public static void Upload(string filePath, string browserType)
        {
            throw new NotImplementedException("File upload being re-architected");//todo: address after control is re-architectec -dg 06/02/2017

            if (browserType == "Grid" || browserType == "Mobile")
            {
                RemoteWebDriverUpload(filePath);
            }

            //get and attach to browser process
            var browser = Application.Attach(Process.GetProcessById(WebDriverFactory.CurrentBrowserPID));

            //get file upload window
            var fileUploadWindow = browser.GetWindows().Where(w => w.Name == "File Upload" || w.Name == "Open").ToArray();
            var x = browser.GetWindows();
            //enter filepath
            var searchCriteria = SearchCriteria
                                 .ByControlType(ControlType.Edit)
                                 .AndAutomationId("1148");
            var fileNameCombo = (TextBox)fileUploadWindow[0].Get(searchCriteria);

            fileNameCombo.Text = filePath;
            WaitHelpers.ExplicitWait(250);
            //click open button
            var openSearch = SearchCriteria
                             .ByControlType(ControlType.Button)
                             .AndAutomationId("1");
            var openButton = (Button)fileUploadWindow[0].Get(openSearch);

            openButton.Click();
            WaitHelpers.ExplicitWait(1000);
            var wait = new WebDriverWait(WebDriverFactory.LastDriver, TimeSpan.FromSeconds(5));

            wait.PollingInterval = TimeSpan.FromSeconds(1);
            wait.Until(
                ExpectedConditions.TextToBePresentInElement(WebDriverFactory.LastDriver.FindElement(By.CssSelector(".k-upload-status")), "Done"));
        }
        /// <summary>
        /// Perform selected operation on a row of a table.
        /// </summary>
        /// <param name="table">IWebElement table</param>
        /// <param name="driver">IWebDriver</param>
        /// <param name="rowNo">Index of row to perform operation.</param>
        /// <param name="operation">Operation to perform</param>
        public static void SelectOperationsForRowsBasedOnValue(this IWebElement table, IWebDriver driver, int rowNo, string operation)
        {
            WaitHelpers.ExplicitWait(200);
            Assert.IsTrue(table.FindElement(By.TagName("tbody")).FindElements(By.TagName("tr")).Count > 0, "Any row with the desired Cell text/date is not found");

            var flag = true;
            table.WaitForPresent(driver);
            WaitHelpers.ExplicitWait(200);
            var row = table.FindElement(By.TagName("tbody")).FindElements(By.TagName("tr"))[rowNo];
            switch (operation)
            {
                case "Edit":
                    row.FindElement(By.XPath("(//i[text()='mode_edit'])[" + (rowNo + 1) + "]")).DrawHighlight(driver);
                    WaitHelpers.WaitForClickable(row.FindElement(By.XPath("(//i[text()='mode_edit'])[" + (rowNo + 1) + "]"))).Click();
                    flag = false;
                    break;

                case "Go To Details":
                    row.FindElement(By.XPath("(//i[text()='keyboard_arrow_right'])[" + (rowNo + 2) + "]")).DrawHighlight(driver);
                    WaitHelpers.WaitForClickable(row.FindElement(By.XPath("(//i[text()='keyboard_arrow_right'])[" + (rowNo + 2) + "]"))).Click();
                    flag = false;
                    break;

                case "Expand_More":
                    //WaitHelpers.WaitForClickable(table.FindElement(By.XPath("(//i[text()='expand_more'])[" + (rowNo + 3) + "]"))).DrawHighlight(driver);
                    WaitHelpers.WaitForClickable(table.FindElement(By.XPath($"(//i[text()='expand_more' and contains(@class, 'actionButton')])[{rowNo + 1}]"))).DrawHighlight(driver);
                    table.FindElement(By.XPath($"(//i[text()='expand_more' and contains(@class, 'actionButton')])[{rowNo + 1}]")).Click();
                    flag = false;
                    break;

                case "Expand_Less":
                    //table.FindElement(By.XPath("(//i[text()='expand_more'])[" + (rowNo + 1) + "]")).DrawHighlight(driver);
                    WaitHelpers.WaitForClickable(table.FindElement(By.XPath($"(//i[contains(text(), 'expand_less') and contains(@class, 'actionButton')])[{rowNo + 1}]"))).DrawHighlight(driver);
                    table.FindElement(By.XPath($"(//i[contains(text(),'expand_less') and contains(@class, 'actionButton')])[{rowNo + 1}]")).Click();
                    flag = false;
                    break;
                
                case "Transfer Credit":
                    var cell = row.FindElement(By.CssSelector(".material-icons.dropdown-toggle"));
                    cell.DrawHighlight(driver);
                    WaitHelpers.WaitForClickable(cell).Click();
                    WaitHelpers.ExplicitWait(250);
                    WaitHelpers.WaitForClickable(table.FindElement(By.XPath($"(//a[text()='Transfer Credit'])[{rowNo + 1}]"))).DrawHighlight(driver);
                    table.FindElement(By.XPath($"(//a[text()='Transfer Credit'])[{rowNo + 1}]")).Click();
                    flag = false;
                    break;

                case "Add New Order":
                    cell = row.FindElement(By.CssSelector(".material-icons.dropdown-toggle"));
                    cell.DrawHighlight(driver);
                    WaitHelpers.WaitForClickable(cell).Click();
                    WaitHelpers.ExplicitWait(250);
                    if (cell.FindElements(By.XPath(".//parent::*//ul//li//a")).Any(e => e.Text.ToLower().Contains("Add New Order".ToLower())))
                    {
                        WaitHelpers.WaitForClickable(cell.FindElements(By.XPath(".//parent::*//ul//li//a")).Where(e => e.Text.ToLower().Contains("Add New Order".ToLower())).ToArray()[0]).Click();
                        flag = false;
                    }
                    break;


                default:
                    cell = row.FindElement(By.CssSelector(".material-icons.dropdown-toggle"));
                    cell.DrawHighlight(driver);
                    WaitHelpers.WaitForClickable(cell).Click();
                    WaitHelpers.ExplicitWait(250);
                    if (cell.FindElements(By.XPath(".//parent::*//ul//li//a")).Any(e => e.Text.ToLower().Equals(operation.ToLower())))
                    {
                        WaitHelpers.WaitForClickable(cell.FindElements(By.XPath(".//parent::*//ul//li//a")).Where(e => e.Text.ToLower().Equals(operation.ToLower())).ToArray()[0]).Click();
                        flag = false;
                    }
                    break;
            }            
            Assert.IsFalse(flag, "The desried operation is not found for the particular row: " + rowNo + "Expected Operation: " + operation);
        }
 /// <summary>
 /// Clicks the element located using the By.
 /// </summary>
 /// <param name="by">By locator of element to click </param>
 public static void Click(this By by)
 {
     WaitHelpers.WaitForClickable(by).Click();
 }
 /// <summary>
 /// Gets the value of the masked currency edit
 /// </summary>
 /// <param name="by">By locator for masked currency edit</param>
 /// <returns>value of the element</returns>
 public static string GetValueMaskedNumberEdit(this By by)
 {
     return WaitHelpers.WaitForElementExist(by).GetValueMaskedNumberEdit();
 }
 /// <summary>
 /// Gets value of Kendo switch
 /// </summary>
 /// <param name="by">By locator for Kendo switch</param>
 /// <returns>Value of Kendo switch.</returns>
 public static bool GetSwitchValue(this By by)
 {
     return WaitHelpers.WaitForElementExist(by).GetSwitchValue();
 }
 /// <summary>
 /// Sets value of Kendo sswitch.
 /// </summary>
 /// <param name="by">By locator for Kendo switch</param>
 /// <param name="value">Value to set switch to.</param>
 public static void SetSwitchValue(this By by, bool value)
 {
     WaitHelpers.WaitForElementExist(by).SetSwitchValue(value);
 }
 /// <summary>
 /// Scrolls IWebElement into view.
 /// </summary>
 /// <param name="ele">IWebElement to scroll into view.</param>
 public static void ScrollIntoView(this IWebElement ele)
 {
     Executor.ExecuteJavascript("arguments[0].scrollIntoView()", ele);
     WaitHelpers.ExplicitWait(250);
 }
 /// <summary>
 /// Gets current value of Kendo ComboDropdown
 /// </summary>
 /// <param name="by">By locator Kendo ComboDropDown</param>
 /// <returns>Current selected value of the combo</returns>
 public static string GetCurrentValueofComboDropdown(this By by)
 {
     return WaitHelpers.WaitForClickable(by).GetCurrentValueofComboDropdown();
 }
 /// <summary>
 /// Sets value of Kendo Masked Textbox with up down toggles.
 /// </summary>
 /// <param name="by">By locator of Kendo masked text box.</param>
 /// <param name="value">value to set.</param>
 public static void SetValueMaskedNumberEdit(this By by, string value)
 {
     WaitHelpers.WaitForElementExist(by).SetValueMaskedNumberEdit(value);
 }
 /// <summary>
 /// Retrieves all values from a Kendo ComboDropDown
 /// </summary>
 /// <param name="by">By locator for Kendo ComboDropDown</param>
 /// <returns>Dictionary with values from the Kendo ComboDropDown element.</returns>
 public static Dictionary<string, string> GetAllValueFromComboDropdown(this By by)
 {
     return WaitHelpers.WaitForClickable(by).GetAllValueFromComboDropdown();
 }
 /// <summary>
 /// Sets text in a standard input element.
 /// </summary>
 /// <param name="by">By locator of the textbox element.</param>
 /// <param name="text">Text to enter into the textbox.</param>
 public static void SetTextStandardTextBox(this By by, string text)
 {
     WaitHelpers.WaitForClickable(by).SetTextStandardTextBox(text);
 }