コード例 #1
0
        public void SetName()
        {
            if (SeleniumConfig.GetBrowserName().Equals("Remote", System.StringComparison.CurrentCultureIgnoreCase))
            {
                try
                {
                    string name = TestContext.FullyQualifiedTestClassName + "." + TestContext.TestName;

                    RemoteBrowserType           remoteBrowser        = SeleniumConfig.GetRemoteBrowserType();
                    string                      remotePlatform       = SeleniumConfig.GetRemotePlatform();
                    string                      remoteBrowserVersion = SeleniumConfig.GetRemoteBrowserVersion();
                    Dictionary <string, object> capabilities         = SeleniumConfig.GetRemoteCapabilitiesAsObjects();
                    capabilities.Add("build", Environment.GetEnvironmentVariable("SAUCE_BUILD_NAME"));
                    capabilities.Add("name", name);
                    capabilities.Add("extendedDebugging", Config.GetValueForSection(ConfigSection.SeleniumMaqs, "extendedDebugging"));

                    var options = WebDriverFactory.GetRemoteOptions(remoteBrowser, remotePlatform, remoteBrowserVersion, capabilities);

                    this.WebDriver = new RemoteWebDriver(SeleniumConfig.GetHubUri(), options.ToCapabilities(), SeleniumConfig.GetCommandTimeout());
                }
                catch (Exception e)
                {
                    Log.LogMessage(MessageType.WARNING, "Failed to set Sauce name because: " + e.Message);
                }
            }
        }
コード例 #2
0
        public new void Teardown()
        {
            try
            {
                bool passed = this.GetResultType() == TestResultType.PASS;

                if (SeleniumConfig.GetBrowserName().Equals("Remote", System.StringComparison.CurrentCultureIgnoreCase))
                {
                    try
                    {
                        // Logs the result to Sauce Labs
                        ((IJavaScriptExecutor)this.WebDriver).ExecuteScript("sauce:job-result=" + (passed ? "passed" : "failed"));
                        ((IJavaScriptExecutor)this.WebDriver).ExecuteScript("sauce:job-build=" + Config.GetGeneralValue("Build", "0.0.0.0"));
                    }
                    catch (Exception e)
                    {
                        this.Log.LogMessage(MessageType.WARNING, "Failed to set Sauce result because: " + e.Message);
                    }
                }
            }
            finally
            {
                base.Teardown();
            }
        }
コード例 #3
0
 public static void AssemblyInit(TestContext context)
 {
     if (SeleniumConfig.GetBrowserName().Equals("Chrome", System.StringComparison.CurrentCultureIgnoreCase))
     {
         new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);
     }
 }
コード例 #4
0
        /// <summary>
        /// Get a Chrome driver setup with emulation
        /// </summary>
        /// <returns>A Chrome driver</returns>
        private IWebDriver EmulateiPhone()
        {
            ChromeOptions options = new ChromeOptions();

            options.EnableMobileEmulation("iPhone 8");

            return(WebDriverFactory.GetChromeDriver(SeleniumConfig.GetCommandTimeout(), options, "DEFAULT"));
        }
コード例 #5
0
        protected override IWebDriver GetBrowser()
        {
            if (SeleniumConfig.GetBrowserName().Equals("Remote", StringComparison.CurrentCultureIgnoreCase))
            {
                return(GetRandom());
            }

            return(SeleniumConfig.Browser());
        }
コード例 #6
0
 public void SetName()
 {
     if (SeleniumConfig.GetBrowserName().Equals("Remote", System.StringComparison.CurrentCultureIgnoreCase))
     {
         try
         {
             string name = TestContext.FullyQualifiedTestClassName + "." + TestContext.TestName;
             ((IJavaScriptExecutor)this.WebDriver).ExecuteScript("sauce:job-name=" + name);
         }
         catch (Exception e)
         {
             this.Log.LogMessage(MessageType.WARNING, "Failed to set Sauce name because: " + e.Message);
         }
     }
 }