Example #1
0
        internal void SetDate(By byFromDate, string p)
        {
            string      From_Date = p.Replace('/', '\0');
            IWebElement fromDate  = driver.FindElement(byFromDate);

            fromDate.SendKeys(Keys.Backspace);
            fromDate.SendKeys(Keys.Backspace);
            fromDate.SendKeys(Keys.Backspace);
            fromDate.SendKeys(Keys.Backspace);
            fromDate.SendKeys(Keys.Backspace);
            fromDate.SendKeys(Keys.Backspace);
            fromDate.SendKeys(Keys.Backspace);
            fromDate.SendKeys(Keys.Backspace);
            if (driver.ToString() == "OpenQA.Selenium.IE.InternetExplorerDriver")
            {
                string[] arDate = From_Date.Split('\0');
                fromDate.SendKeys(arDate[0]);
                fromDate.SendKeys(arDate[1]);
                fromDate.SendKeys(arDate[2]);
            }
            else
            {
                fromDate.SendKeys(From_Date);
            }
            fromDate.SendKeys(Keys.Tab);
        }
Example #2
0
 public void NavegadorAberto()
 {
     Assert.IsTrue(driverNavegadorChrome.ToString().Contains("Chrome"));
 }
Example #3
0
        /// <summary>
        /// Method to close current browser associate with web driver 
        /// </summary>
        public void CloseBrowser()
        {
            try
            {
                try
                {
                    switchToMostRecentBrowser();
                }
                catch
                {
                    // ignored
                }
                try
                {

                    Driver.Close();
                    Thread.Sleep(3000);
                    if (Driverlist.Count > 1)
                    {
                        for (int i = Driverlist.Count - 1; i >= 0; i--)
                        {
                            try
                            {
                                Driver = Driverlist[i];
                                string window = switchToMostRecentBrowser();
                                Driver = Driver.SwitchTo().Window(window);
                                Driver.Title.ToString();  // Test for Exception with current driver.
                                break;
                            }
                            catch (Exception)
                            {
                                // ignored
                            }
                        }
                        if (Driver.ToString().IndexOf("InternetExplorer", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            BrowserName = "ie";
                            _driverName = "InternetExplorerDriver";

                        }
                        else if (Driver.ToString().IndexOf("chrome", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            _driverName = "ChromeDriver";
                            BrowserName = "chrome";
                        }
                        else if (Driver.ToString().IndexOf("Firefox", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            _driverName = "FirefoxDriver";
                            BrowserName = "Firefox";
                        }
                        else if (Driver.ToString().IndexOf("Safari", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            _driverName = "SafariDriver";
                            BrowserName = "Safari";
                        }
                        TestObject.Driver = Driver;
                        Driver = TestObject.Driver;
                    }
                }
                catch (Exception)
                {
                    //Do nothing No browser to close.
                }
                if (BrowserName.ToLower().Equals("firefox") && Property.ArrKnownBrowserHwnd.Count().Equals(1))
                {
                    WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));
                    Func<IWebDriver, bool> condition = ProfileRunningCondition;
                    try
                    {
                        wait.Until(condition);
                    }
                    catch
                    {
                        // ignored
                    }
                }

            }
            catch (WebDriverException e)
            {
                if (e.Message.Contains("No response from server for url"))
                {
                    throw new WebDriverException(Utility.GetCommonMsgVariable("KRYPTONERRCODE0007") + ":" + e.Message);
                }
                throw new Exception(Utility.GetCommonMsgVariable("KRYPTONERRCODE0054") + ":" + e.Message);
            }

            catch (NullReferenceException e)
            {
                throw new NullReferenceException(Utility.GetCommonMsgVariable("KRYPTONERRCODE0010") + ":" + e.Message);
            }

            catch (Exception e)
            {
                throw new Exception(Utility.GetCommonMsgVariable("KRYPTONERRCODE0054") + ":" + e.Message);
            }
        }
Example #4
0
        //this method set arrKnownBrowserHwnd in TestObject class.
        /// <summary>
        /// Method to close current browser associate with web driver 
        /// </summary>
        public void CloseBrowser()
        {
            try
            {
                try
                {
                    switchToMostRecentBrowser();
                }
                catch
                { }

                //back to previous different browser.
                try
               {

                   driver.Close();
                   Thread.Sleep(3000);
                    if (driverlist.Count > 1)
                    {
                        for (int i = driverlist.Count - 1; i >= 0; i--)
                        {
                            try
                            {
                                driver = driverlist[i];
                                string window = switchToMostRecentBrowser();
                                driver = driver.SwitchTo().Window(window);
                                driver.Title.ToString();  // Test for Exception with current driver.
                                break;
                            }
                            catch (Exception exx)
                            {
                                continue;
                            }

                        }
                        if (driver.ToString().IndexOf("InternetExplorer", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            browserName = KryptonConstants.BROWSER_IE;
                            driverName = "InternetExplorerDriver";

                        }
                        else if (driver.ToString().IndexOf(KryptonConstants.BROWSER_CHROME, StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            driverName = KryptonConstants.CHROME_DRIVER;
                            browserName = KryptonConstants.BROWSER_CHROME;
                        }
                        else if (driver.ToString().IndexOf(KryptonConstants.BROWSER_FIREFOX, StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            driverName = KryptonConstants.FIREFOX_DRIVER;
                            browserName = KryptonConstants.BROWSER_FIREFOX;
                        }
                        else if (driver.ToString().IndexOf(KryptonConstants.BROWSER_SAFARI, StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            driverName = KryptonConstants.SAFARI_DRIVER;
                            browserName = KryptonConstants.BROWSER_SAFARI;
                        }
                        Driver.TestObject.driver = driver;
                        Driver.Browser.driver = Driver.TestObject.driver;
                    }
                }
                catch (Exception ex)
                {
                    //Do nothing No browser to close.
                 }

                if (browserName.ToLower().Equals(KryptonConstants.BROWSER_FIREFOX) && Property.arrKnownBrowserHwnd.Count().Equals(1))
                {
                    WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                    Func<IWebDriver, bool> condition = this.ProfileRunningCondition;
                    try
                    {
                        wait.Until(condition);
                    }
                    catch
                    {

                    }
                }

            }
            catch (WebDriverException e)
            {
                if (e.Message.Contains(Common.exceptions.ERROR_NORESPONSEURL))
                {
                    throw new WebDriverException(Common.Utility.GetCommonMsgVariable("KRYPTONERRCODE0007") + ":" + e.Message);
                }
                throw new Exception(Common.Utility.GetCommonMsgVariable("KRYPTONERRCODE0054") + ":" + e.Message);
            }

            catch (NullReferenceException e)
            {
                throw new NullReferenceException(Common.Utility.GetCommonMsgVariable("KRYPTONERRCODE0010") + ":" + e.Message);
            }

            catch (Exception e)
            {
                throw new Exception(Common.Utility.GetCommonMsgVariable("KRYPTONERRCODE0054") + ":" + e.Message);
            }
        }