public void SetupPerTest()
        {
            string browserName           = string.Empty;
            string defaultDownloadFolder = string.Empty;
            string projectDirectoryPath  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            try
            {
                browserName           = WebEnvironment.AppSettings["BrowserType"].ToLower();
                defaultDownloadFolder = WebEnvironment.AppSettings["DefaultDownloadFolder"].ToLower();
                WebEnvironment env = new WebEnvironment();

                if (string.IsNullOrWhiteSpace(defaultDownloadFolder))
                {
                    env.InitializeDriver(browserName, projectDirectoryPath);
                }
                else
                {
                    switch (browserName)
                    {
                    case "chrome":
                        var driverOptions = new ChromeOptions();
                        driverOptions.AddUserProfilePreference("download.default_directory", defaultDownloadFolder);
                        env.InitializeDriverWithOptions(browserName, null, driverOptions, projectDirectoryPath);
                        //GlobalData.Set(GlobalDataKeys.DOWNLOAD_FOLDER, defaultDownloadFolder);
                        break;

                    //case "saucelabs":
                    //    if (WebEnvironment.AppSettings["BrowserType"].ToLower() == "saucelabs")
                    //    {
                    //        env.InitializeDriver(browserName);
                    //        string TestName = TestContext.CurrentContext.Test.Name;
                    //        string BuildName = TestContext.CurrentContext.Test.Properties.Get("Category").ToString();
                    //        ((IJavaScriptExecutor)DriverManager.Driver).ExecuteScript("sauce:job-name=" + TestName);
                    //        ((IJavaScriptExecutor)DriverManager.Driver).ExecuteScript("sauce:job-build=" + BuildName);
                    //    }
                    //    break;
                    case "ie":
                        env.InitializeDriver(browserName);
                        break;

                    default:
                        Log.Info("Error intializing: " + browserName);
                        break;
                    }
                }
                System.Drawing.Size s = new System.Drawing.Size();
                s = SystemInformation.PrimaryMonitorSize;
                DriverManager.Driver.Manage().Window.Size = s;
            }
            catch (Exception e)
            {
                CustomExceptionHandler.CustomException(e, "Error occurred while trying to launch '" + browserName + "'.");
            }
        }
Exemple #2
0
        public static void TranstemLabTimeSetup()
        {
            string browserName = string.Empty;

            try
            {
                browserName = WebEnvironment.AppSettings["BrowserType"].ToLower();
                bddHooks.Environment.InitializeDriver(browserName);
            }
            catch (Exception e)
            {
                CustomExceptionHandler.CustomException(e, "Error occurred while trying to launch '" + browserName + "'.");
            }
        }
Exemple #3
0
        public static void ORTOneTimeSetup()
        {
            string browserName = string.Empty;

            try

            {
                browserName = WebEnvironment.AppSettings["BrowserType"].ToLower();
                BddTestBase.Environment.InitializeDriver(browserName);

                //GlobalData.Set("LandingPageHandle", bddHooks.Environment.Driver.CurrentWindowHandle);
            }

            catch (Exception e)

            {
                CustomExceptionHandler.CustomException(e, "Error occurred while trying to launch '" + browserName + "'.");
            }
        }