public bool sSelectorSelect(IWebElement element, string text)
        {
            WaitUtilities.WaitForPostBack(_webDriver);


            if (!element.Displayed)
            {
                Debug.WriteLine("ERROR: Selector Is not available to fill");
                Debug.WriteLine("Selector ID: " + element.GetAttribute("id"));
                return(false);
            }

            if (element.GetAttribute("value") == text || element.Text == text) // TODO: WATCH THIS, GW is wonky and it may not always be value
            {
                return(true);
            }

            sClick(element);

            if (_webDriver.FindElementByXPath("//li[contains(text(), '" + text + "')]").Displayed)
            {
                sClick(_webDriver.FindElementByXPath("//li[contains(text(), '" + text + "')]"));
                Thread.Sleep(50);
            }

            return(true);
        }
        public bool clickSearchSubmission()
        {
            OpenQA.Selenium.Interactions.Actions builder = new OpenQA.Selenium.Interactions.Actions(_webDriver);

            builder.MoveToElement(btnSearchTab)
            .MoveByOffset(30, 0)
            .Click()
            .Build()
            .Perform();
            WaitUtilities.WaitForPostBack(_webDriver);
            return(sClick(btnSubmissionSearch));
        }
        public void TriggerPostBack(IWebElement element)
        {
            WaitUtilities.WaitForPostBack(_webDriver);


            if (_webDriver.FindElementByXPath("//img[contains(@class,'product-logo')]").Displayed)
            {
                sClick(_webDriver.FindElementByXPath("//img[contains(@class,'product-logo')]"));
            }
            else
            {
                element.SendKeys(Keys.Tab);
                WaitUtilities.WaitForPostBack(_webDriver);
            }
        }
 public bool Login(string User, string Password)
 {
     if (IsAt() && (txtUserName.Displayed && txtPassword.Displayed && btnUserName.Displayed))
     {
         WaitUtilities.WaitForPostBack(_webDriver);
         sSendKeys(txtUserName, User);
         sSendKeys(txtPassword, Password);
         sClick(btnUserName);
         WaitUtilities.WaitForPostBack(_webDriver);
         return(true);
     }
     else
     {
         Debug.WriteLine("ERROR: Unable to login!");
         return(false);
     }
 }
        //[OneTimeSetUp]
        public void Initialize(string center)
        {
            Browser   = new BrowserBase();
            Pages     = new PagesBase(Browser);
            WorkFlows = new WorkFlowsBase(Pages);
            ChromeOptions options = new ChromeOptions();

            options.AddArgument("start-maximized");
            //options.AddArgument("--log-level=3");
            //options.AddArgument("--silent");
            //options.AddArgument("--disable-logging");
            //options.AddArgument("sync-short-nudge-delay-for-test");
            options.Proxy = null;
            ChromeDriver driver = new ChromeDriver(ResourcesBase.ChromeDriverPath, options);

            Browser.Initialize(driver, center);
            _webDriver = driver;
            Thread.Sleep(RandomNumberGeneratorUtilities.GetRandomNumber(10) * 100 + 3000);
            WaitUtilities.WaitForPostBack(_webDriver);
        }
        // Use this selector when there are multiple selectors with the same set of values to choose from
        public bool sAltSelectorSelect(IWebElement element, string text)
        {
            WaitUtilities.WaitForPostBack(_webDriver);


            if (!element.Displayed)
            {
                Debug.WriteLine("ERROR: Selector Is not available to fill");
                Debug.WriteLine("Selector ID: " + element.GetAttribute("id"));
                return(false);
            }

            if (element.GetAttribute("value") == text || element.Text == text) // TODO: WATCH THIS, GW is wonky and it may not always be value
            {
                return(true);
            }

            WaitUtilities.WaitForPostBack(_webDriver);
            sClick(element);
            WaitUtilities.WaitForPostBack(_webDriver);
            sSendKeys(element, text);
            return(true);
        }
        public bool sSendKeys(IWebElement element, string text)
        {
            //WaitUtilities.WaitForPostBack(_webDriver);


            bool done       = false;
            int  numRetries = 0;

            while (!done && numRetries < 50)
            {
                try
                {
                    if (!element.Displayed)
                    {
                        element.Click();
                        Thread.Sleep(100);
                        if (!element.Displayed)
                        {
                            element.Click();
                            Thread.Sleep(100);
                            if (!element.Displayed)
                            {
                                WaitUtilities.WaitForPostBack(_webDriver);
                                element.Click();
                                Thread.Sleep(300);
                                if (!element.Displayed)
                                {
                                    Debug.WriteLine("ERROR: TextBox Is not available to fill");
                                    Debug.WriteLine("TextBox ID: " + element.GetAttribute("id"));
                                    return(false);
                                }
                            }
                        }
                    }
                    done = true;
                }
                catch (WebDriverException)
                {
                    WaitUtilities.WaitForPostBack(_webDriver);
                    numRetries++;
                }
            }

            // Optimization to not enter if it's already set.. saves postback time!
            if (element.GetAttribute("value") == text || element.Text == text) // TODO: WATCH THIS, GW is wonky and it may not always be value
            {
                return(true);
            }
            element.Clear();

            try
            {
                element.SendKeys(text);
            }
            catch (StaleElementReferenceException)
            {
                Thread.Sleep(500);
                element.SendKeys(text);
            }

            TriggerPostBack(element);
            return(true);
        }
        public bool sClick(IWebElement element)
        {
            //WaitUtilities.WaitForPostBack(_webDriver);


            if (!element.Displayed && !element.GetAttribute("class").Contains("disabled"))
            {
                Debug.WriteLine("ERROR: Button Is not available to click");
                Debug.WriteLine("Button ID: " + element.GetAttribute("id"));
                return(false);
            }

            try
            {
                element.Click();
            }
            catch (WebDriverException)
            {
                try
                {
                    Thread.Sleep(25);
                    element.Click();
                }
                catch (WebDriverException)
                {
                    try
                    {
                        Thread.Sleep(25);
                        element.Click();
                    }
                    catch (WebDriverException)
                    {
                        try
                        {
                            WaitUtilities.WaitForPostBack(_webDriver);
                            element.Click();
                        }
                        catch (WebDriverException)
                        {
                            try
                            {
                                WaitUtilities.WaitForPostBack(_webDriver);
                                element.Click();
                            }
                            catch (WebDriverException)
                            {
                                try
                                {
                                    WaitUtilities.WaitForPostBack(_webDriver);
                                    element.Click();
                                }
                                catch (WebDriverException)
                                {
                                    try
                                    {
                                        WaitUtilities.WaitForPostBack(_webDriver);
                                        element.Click();
                                    }
                                    catch (WebDriverException)
                                    {
                                        WaitUtilities.WaitForPostBack(_webDriver);
                                        element.Click();
                                    }
                                }
                            }
                        }
                    }
                }
            }

            WaitUtilities.WaitForPostBack(_webDriver);
            return(true);
        }