当前位置: 首页>>代码示例>>C#>>正文


C# IWebDriver.ToString方法代码示例

本文整理汇总了C#中IWebDriver.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IWebDriver.ToString方法的具体用法?C# IWebDriver.ToString怎么用?C# IWebDriver.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWebDriver的用法示例。


在下文中一共展示了IWebDriver.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CloseBrowser

        /// <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);
            }
        }
开发者ID:Thinksys,项目名称:krypton,代码行数:100,代码来源:Browser.cs

示例2: CloseBrowser

        //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)
            {
//.........这里部分代码省略.........
开发者ID:Thinksys,项目名称:krypton,代码行数:101,代码来源:Browser.cs


注:本文中的IWebDriver.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。