コード例 #1
0
        /// <summary>
        /// Parse the web environment provided.
        /// </summary>
        /// <param name="environment"> the environment string</param>
        /// <returns> the WebEnvironmnet for ParallelRunner</returns>
        public static WebEnvironment ParseWebEnvironment(string environment)
        {
            // example of environment string for web
            // "browser: Chrome"

            var dictionary = GetEnvironmentProperties(environment);

            if (!dictionary.ContainsKey(BrowserKey.ToLower()))
            {
                return(null);
            }

            WebEnvironment webEnvironment = new WebEnvironment {
                lab = WebLab
            };

            var browser = dictionary[BrowserKey.ToLower()];

            // try to find a browser that matches the one provided
            foreach (var browserName in BrowserNames)
            {
                if (string.Equals(browserName, browser, StringComparison.CurrentCultureIgnoreCase))
                {
                    webEnvironment.browser = dictionary[BrowserKey.ToLower()];
                    return(webEnvironment);
                }
            }

            return(null);
        }
コード例 #2
0
        public void Go(WebEnvironment link)
        {
            switch (link)
            {
            case WebEnvironment.TestEnvironment:
                GotoUrl("https://abtassoctest.service-now.com/navpage.do");
                // GotoUrl("https://abtassociates.okta.com/home/servicenow_app2/0oa80tx9crDmIcRfk0x7/14155");
                //  Console.WriteLine("Service Now (Test) Home Page Took: " + LoadTime + " to load Using Okta");
                //   Console.WriteLine("</br>");
                SSOProvider       = "Okta";
                portalEnvironment = "Test";
                break;

            case WebEnvironment.ProductionEnvironment:
                GotoUrl("https://abtassociates.service-now.com/navpage.do");
                //      Console.WriteLine("Service Now (Production) Home Page Took: " + LoadTime + " to load Using Simieo");
                //    Console.WriteLine("</br>");
                SSOProvider       = "Simieo";
                portalEnvironment = "Production";
                break;

            default:
                break;
            }
        }
コード例 #3
0
 private WebEnvironment GetEnvironment()
 {
     var environment = new WebEnvironment();
     environment.HttpContext = _httpContextMock.Object;
     _httpContextMock.Setup(m => m.Session).Returns(_sessionMock.Object);
     return environment;
 }
コード例 #4
0
        /// <summary>
        ///     Returns a link to the product stock image
        /// </summary>
        /// <param name="productID"></param>
        /// <returns></returns>
        public ActionResult ProductImage(int productID)
        {
            // Nothing fancy here, just redirect to hard-coded image files for this demo app
            string path = new WebEnvironment().MapPath("~/content/i/products/" + productID + ".png");

            return(File(path, "image/png"));
        }
        public void ParseWebEnvironmentTest_EmptyWebEnvironment_ReturnsExpectedWebEnvironment()
        {
            WebEnvironment webEnvironment = ParallelRunnerEnvironmentUtil.
                                            ParseWebEnvironment("");

            // function suceeded
            Assert.IsNull(webEnvironment);
        }
コード例 #6
0
 public CommonActions(WebEnvironment testEnvironment)
 {
     TestEnvironment = testEnvironment;
     Waits           = new WebWaits(testEnvironment);
     Actions         = new WebActions(testEnvironment);
     Driver          = new DriverManager();
     Verify          = new WebVerify(testEnvironment);
     Logger          = new Logger();
 }
        public void ParseWebEnvironmentTest_InvalidKeyWebEnvironment_ReturnsExpectedWebEnvironment()
        {
            string invalidKey = "brows: Chrome";

            WebEnvironment webEnvironment = ParallelRunnerEnvironmentUtil.
                                            ParseWebEnvironment(invalidKey);

            // function suceeded
            Assert.IsNull(webEnvironment);
        }
コード例 #8
0
        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 + "'.");
            }
        }
コード例 #9
0
        /// <summary>
        ///     Appends the version number to this content
        /// </summary>
        /// <param name="url"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public static string ContentWithVersion(this UrlHelper url, string path)
        {
            if (url == null)
            {
                return("");
            }

            path = path ?? "";

            // Requires URL rewrite to work

            path = path.TrimStart(new[] { '~', '/' });
            path = "~/" + VersionInfo.AssemblyVersion + "/" + path;
            path = new WebEnvironment().GetFullUrl(path);
            return(path);
        }
        public void ParseWebEnvironmentTest_ValidWebEnvironment_ReturnsExpectedWebEnvironment()
        {
            WebEnvironment webEnvironment = ParallelRunnerEnvironmentUtil.
                                            ParseWebEnvironment(WebEnvironment);

            // function suceeded
            Assert.IsNotNull(webEnvironment);

            // browser should be present
            Assert.IsNotNull(webEnvironment.browser);

            // local browser lab should be present
            Assert.IsNotNull(webEnvironment.lab);

            // browser should be 'chrome'
            Assert.AreEqual("chrome", webEnvironment.browser);

            Assert.AreEqual("LocalBrowser", webEnvironment.lab);
        }
コード例 #11
0
        public void Go(WebEnvironment link)
        {
            switch (link)
            {
            case WebEnvironment.TestEnvironment:
                GoToUrl("https://abtassoc-test.webex.com");
                Console.WriteLine("WebEx Test HomePage took: " + LoadTime + " to load using okta");

                break;

            case WebEnvironment.ProductionEnvironment:
                GoToUrl("https://abtassociates.webex.com");
                Console.WriteLine("WebEx Production HomePage took: " + LoadTime + "to load using simieo");
                break;

            default:
                break;
            }
        }
コード例 #12
0
        public void Go(WebEnvironment link)
        {
            switch (link)
            {
            case WebEnvironment.TestEnvironment:
                GoToUrl("https://abtassociates.okta.com/home/successfactors/0oa7asr5nxwVWgWVw0x7/38");
                _Environment         = "Test";
                SingleSignOnProvider = "Okta";
                break;

            case WebEnvironment.ProductionEnvironment:
                GoToUrl("https://daxii.abtassoc.com/openam/idpssoinit?metaAlias=/abt/AbtSaml2Idp&spEntityID=https://www.successfactors.com&binding=HTTP-POST&NameIDFormat=urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified&RelayState=/sf/home/&iPSPCookie=Yes");
                _Environment         = "Production";
                SingleSignOnProvider = "Simieo";
                break;

            default:
                break;
            }
        }
コード例 #13
0
 //ctl00_ctl00_MainContentArea_MainContentArea_EmailAddressTBox
 public void Go(WebEnvironment link)
 {
     switch (link)
     {
         case WebEnvironment.TestEnvironment:
              GoToUrl("https://search.ebscohost.com/login.aspx?authtype=sso&custid=aspengreg&profile=eds");
            // GoToUrl("https://abtassociates.okta.com/home/abtassociatesinc_ebsco_1/0oa6yt0cwiVmFJzGB0x7/aln6yt83icACOfcNZ0x7");
             SingleSignOnProvider = "Okta";
             _Environment = "Test";
            
             break;
         case WebEnvironment.ProductionEnvironment:
             GoToUrl("http://search.ebscohost.com/login.aspx?authtype=sso&custid=s1139472&profile=eds");
             SingleSignOnProvider = "Simieo";
             _Environment = "Production";
            
             break;
         default:
             break;
     }
 }
コード例 #14
0
        public void Go(WebEnvironment environment)
        {
            switch (environment)
            {
            case WebEnvironment.TestEnvironment:
                _Environment         = "Test";
                SingleSignOnProvider = "Okta";
                //  GoToUrl("https://rfetest.infotrieve.com/vlib/logon.aspx?clientid=11397");
                GoToUrl("https://abtassociates.okta.com/home/abtassociatesinc_rightfindtest_1/0oa7irrou8UflAXZJ0x7/aln7irw3gcNMEvNG60x7");
                break;

            case WebEnvironment.ProductionEnvironment:
                _Environment         = "Production";
                SingleSignOnProvider = "Simieo";
                GoToUrl("https://www.rightfind.com/vlib/rfe.aspx");
                break;

            default:
                break;
            }
        }
コード例 #15
0
        public static string GetHTML(string url, Encoding enc, WebEnvironment webE)
        {
            string text = string.Empty;

            try
            {
                //HttpWebRequestの作成
                System.Net.HttpWebRequest webreq =
                    (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
                //               webreq.Timeout = webreq.Timeout * timeout;
                //HttpWebResponseの取得
                webreq.UserAgent = webE.UserAgent;
                webreq.Referer   = webE.Referer;



                System.Net.HttpWebResponse webres =
                    (System.Net.HttpWebResponse)webreq.GetResponse();


                //応答データを受信するためのStreamを取得
                System.IO.Stream st = webres.GetResponseStream();

                List <byte> byteArray = new List <byte>();
                int         b;
                while ((b = st.ReadByte()) > -1)
                {
                    byteArray.Add((byte)b);
                }

                byte[] byteArray2 = byteArray.ToArray();
                text = enc.GetString(byteArray2);
            }
            catch
            {
                text = string.Empty;
            }
            return(text);
        }
コード例 #16
0
        public void Go(WebEnvironment links)
        {
            switch (links)
            {
            case WebEnvironment.TestEnvironment:
                // GoToUrl("https://abtxchange.staging.wespire.com/");
                GoToUrl("https://abtassociates.okta.com/home/abtassociatesinc_wespiretest_1/0oa74oid9ekb7tcYS0x7/aln74op8m0ZOi56TI0x7");
                Console.WriteLine("WeSpire (Test) Home Page Took: " + LoadTime + " to load Using Okta");
                Console.WriteLine("</br>");
                SSOProvider = "Okta";
                break;

            case WebEnvironment.ProductionEnvironment:
                GoToUrl("https://abtassociates.wespire.com/");
                Console.WriteLine("WeSpire (Production) Home Page Took: " + LoadTime + " to load Using Simieo");
                Console.WriteLine("</br>");
                SSOProvider = "Simieo";
                break;

            default:
                break;
            }
        }
コード例 #17
0
 public CommonFunctions(WebEnvironment testEnvironment)
 {
     TestEnvironment = testEnvironment;
     Waits = new WebWaits(testEnvironment);
     Actions = new WebActions(testEnvironment);
 }