Beispiel #1
0
        internal static void SelectFilterByText(IWebElement Combobox, By data, string value, int timeout = mediumTimeout, bool isEqual = true)
        {
            Combobox.ActionsClick();

            WaitForElement(data, timeout);
            List <IWebElement> items = GetElementsWithSize(data, 1);

            if (isEqual)
            {
                foreach (IWebElement item in items)
                {
                    if (item.Text.Trim().Equals(value) || item.GetAttribute("innerHTML").Trim().Equals(value))
                    {
                        item.ClickOnElement();
                        break;
                    }
                }
            }
            else
            {
                foreach (IWebElement item in items)
                {
                    if (item.Text.Trim().Contains(value) || item.GetAttribute("innerHTML").Trim().Contains(value))
                    {
                        item.ClickOnElement();
                        break;
                    }
                }
            }
        }
Beispiel #2
0
        internal static void SwitchToNewPopUpWindow(IWebElement ElementToBeClicked, out string parentWindow, bool closePreviousWindow = false, bool doubleClick = false, int timeout = 30)
        {
            parentWindow = WebDriver.CurrentWindowHandle;
            ReadOnlyCollection <string> originalHandles = WebDriver.WindowHandles;

            try
            {
                if (doubleClick == true)
                {
                    ScrollIntoView(ElementToBeClicked);
                    ElementToBeClicked.ClickTwice();
                }
                else
                {
                    ElementToBeClicked.ActionsClick();
                }

                string popUpWindowHandle = Browser.Wait(timeout).Until <string>((d) =>
                {
                    string foundHandle = null;

                    // Subtract out the list of known handles. In the case of a single
                    // popup, the newHandles list will only have one value.
                    List <string> newHandles = WebDriver.WindowHandles.Except(originalHandles).ToList();
                    if (newHandles.Count > 0)
                    {
                        foundHandle = newHandles[0];
                    }

                    return(foundHandle);
                });
                if (closePreviousWindow == true)
                {
                    Browser.Close();
                }
                WebDriver.SwitchTo().Window(popUpWindowHandle);
                WebDriver.Manage().Window.Maximize();
            }
            catch (WebDriverTimeoutException e)
            {
                Console.WriteLine(e.Message);
            }
        }