Example #1
0
        public static bool ValidateSignedIn(IWebDriver driver, TaskConfiguration config)
        {
            IWebElement signOutButton = driver.FindElement(By.Id("idp_SignOutPanel"));

            LogAndScreenshot(driver, config);
            return(signOutButton != null);
        }
Example #2
0
        public static void GoToIdpSignOnPage(IWebDriver driver, TaskConfiguration config)
        {
            string url = $"https://{config.Farm.FarmName}/adfs/ls/idpinitiatedsignon";

            driver.Navigate().GoToUrl(url);
            LogAndScreenshot(driver, config);
        }
Example #3
0
        public static void ClickSignInOnIdpPage(IWebDriver driver, TaskConfiguration config)
        {
            IWebElement signInButton = driver.FindElement(By.Id("idp_SignInButton"));

            signInButton.Click();
            LogAndScreenshot(driver, config);
        }
Example #4
0
        public static void EnterCorrectUsernameAndTab(IWebDriver driver, TaskConfiguration config)
        {
            IWebElement usernameField = driver.FindElement(By.Id("userNameInput"));

            usernameField.SendKeys($"{config.User.CorrectUsername}");
            LogAndScreenshot(driver, config);
            usernameField.SendKeys(Keys.Tab);
        }
        public static void SelectFormsOnOptionPage(IWebDriver driver, TaskConfiguration config)
        {
            LogAndScreenshot(driver, config);

            IWebElement passwordOption = driver.FindElement(By.Id("FormsAuthentication"));

            passwordOption.Click();
        }
Example #6
0
 public static void LogAndScreenshot(IWebDriver driver, TaskConfiguration config)
 {
     Console.WriteLine($"Current Page Title: {driver.Title}");
     if (config.ScreenshotData.ShouldScreenshot)
     {
         Screenshot ss = (( ITakesScreenshot )driver).GetScreenshot();
         ss.SaveAsFile($"{ DateTime.Now:yyyy - MM - dd_hh - mm - ss - fff}.png", ScreenshotImageFormat.Png);
     }
 }
        public static void SelectCertOnOptionPage(IWebDriver driver, TaskConfiguration config)
        {
            LogAndScreenshot(driver, config);

            IWebElement certOption = driver.FindElement(By.Id("CertificateAuthentication"));

            certOption.Click();

            LogAndScreenshot(driver, config);
        }
        public static void SelectExternalOnOptionPage(IWebDriver driver, TaskConfiguration config)
        {
            LogAndScreenshot(driver, config);

            IWebElement externalOption = driver.FindElement(By.Id("ExternalAuth"));

            externalOption.Click();

            LogAndScreenshot(driver, config);
        }
        public static void SignInWithOtherOptions(IWebDriver driver, TaskConfiguration config)
        {
            LogAndScreenshot(driver, config);

            IWebElement otherOption = driver.FindElement(By.Id("otherOptions"));

            otherOption.Click();

            LogAndScreenshot(driver, config);
        }
Example #10
0
        public static void UsernamePageForwardNavigate(IWebDriver driver, TaskConfiguration config)
        {
            LogAndScreenshot(driver, config);

            IWebElement nextButton = driver.FindElement(By.Id("nextButton"));

            nextButton.Click();

            LogAndScreenshot(driver, config);
        }
Example #11
0
        public static void OptionsPageBackNavigate(IWebDriver driver, TaskConfiguration config)
        {
            LogAndScreenshot(driver, config);

            IWebElement backButton = driver.FindElement(By.Id("optionsBackButton"));

            backButton.Click();

            LogAndScreenshot(driver, config);
        }
Example #12
0
        public static void EnterCorrectPassword(IWebDriver driver, TaskConfiguration config)
        {
            LogAndScreenshot(driver, config);

            IWebElement passwordField = driver.FindElement(By.Id("passwordInput"));

            passwordField.SendKeys($"{config.User.CorrectPassword}");
            passwordField.SendKeys(Keys.Return);
            LogAndScreenshot(driver, config);
        }
Example #13
0
        // TODO: Add tasks to use 'Next' button instead of Return key

        public static void EnterMisformattedUsername(IWebDriver driver, TaskConfiguration config)
        {
            IWebElement usernameField = driver.FindElement(By.Id("userNameInput"));

            usernameField.SendKeys($"{config.User.MisformattedUsername}");
            usernameField.SendKeys(Keys.Return);

            // TODO: Validate that the error message appears

            LogAndScreenshot(driver, config);
        }
        /// <summary>
        /// A task to enter an answer to a challenge question provided by an External Auth Provider
        /// that prompts with challenge questions
        ///
        /// Note: This External Auth Adapter is based on a test auth adapter used by the AD FS Product Group
        ///
        /// </summary>
        /// <param name="driver">A web driver</param>
        /// <param name="config">Configuration data for this task</param>
        public static void EnterChallengeAnswers(IWebDriver driver, TaskConfiguration config)
        {
            LogAndScreenshot(driver, config);

            foreach (string answer in config.ExternalAuth.Answers)
            {
                IWebElement challengeField = driver.FindElement(By.Id("challengeQuestionInput"));
                challengeField.SendKeys($"{answer}");
                challengeField.SendKeys(Keys.Return);
                LogAndScreenshot(driver, config);
            }
        }
Example #15
0
        /// <summary>
        /// ENVIRONMENT REQUIREMENTS:
        ///     1. Paginated UI feature disabled
        /// </summary>
        /// <param name="driver"></param>
        static void BasicIdpSignOn_Password_Failure_Legacy(IWebDriver driver, TaskConfiguration configuration)
        {
            // Perform UI Operations
            IdpPageTasks.GoToIdpSignOnPage(driver, configuration);
            IdpPageTasks.ClickSignInOnIdpPage(driver, configuration);
            FormsPageTasks.EnterCorrectUsername(driver, configuration);
            FormsPageTasks.EnterBadPassword(driver, configuration);

            // Perform test validation
            var success = IdpPageTasks.ValidateSignedIn(driver, configuration);

            Debug.Assert(success);

            // Cleanup
            driver.Quit();
        }
Example #16
0
        /// <summary>
        /// ENVIRONMENT REQUIREMENTS:
        ///     1. Paginated UI feature enabled
        ///     2. Multiple auth options available (including external)
        ///     3. User configured for external auth
        /// </summary>
        /// <param name="driver"></param>
        static void HintIdpSignOn_WithOptions_External(IWebDriver driver, TaskConfiguration configuration)
        {
            // Perform UI Operations
            IdpPageTasks.GoToIdpSignOnPageWithLoginHint(driver, configuration);
            IdpPageTasks.ClickSignInOnIdpPage(driver, configuration);
            OptionsPageTasks.SelectExternalOnOptionPage(driver, configuration);
            ExternalAuthTasks.EnterChallengeAnswers(driver, configuration);

            // Perform test validation
            var success = IdpPageTasks.ValidateSignedIn(driver, configuration);

            Debug.Assert(success);

            // Cleanup
            driver.Quit();
        }
Example #17
0
        public TestContext()
        {
            TestListConfiguration testListConfig = ( TestListConfiguration )System.Configuration.ConfigurationManager.GetSection("testListConfigurationGroup/testListConfiguration");
            List <string>         testCases      = new List <string>(testListConfig.TestData.TestIds);

            this.TestCases = this.TestCases = ParseAndVerifyTestIds(testCases);

            this.Configuration = TaskConfigurationFactory.GetConfiguration();

            this.DriversPerTestCase = new Dictionary <MethodInfo, List <DesiredCapabilities> >();
            foreach (var testcase in this.TestCases)
            {
                this.DriversPerTestCase[testcase] = new List <DesiredCapabilities> {
                    DriverFactory.GetChromeDriverCapabilities()
                };
            }
        }
Example #18
0
        /// <summary>
        /// ENVIRONMENT REQUIREMENTS:
        ///     1. Paginated UI feature enabled
        ///     2. Multiple auth options available
        ///     3. Relying party exists, and user has access to it
        /// </summary>
        /// <param name="driver"></param>
        static void BasicRpSignOn_WithOptions_Password(IWebDriver driver, TaskConfiguration configuration)
        {
            // Perform UI Operations
            RelyingPartyTasks.GoToRpSignIn(driver, configuration);
            FormsPageTasks.EnterCorrectUsername(driver, configuration);
            OptionsPageTasks.SelectFormsOnOptionPage(driver, configuration);
            FormsPageTasks.EnterBadPassword(driver, configuration);
            OptionsPageTasks.SelectFormsOnOptionPage(driver, configuration);
            FormsPageTasks.EnterCorrectPassword(driver, configuration);

            // Perform test validation
            var success = RelyingPartyTasks.ValidateRpIsSignedIn(driver, configuration);

            Debug.Assert(success);

            // Clean up
            driver.Quit();
        }
Example #19
0
        /// <summary>
        /// ENVIRONMENT REQUIREMENTS:
        ///     1. Paginated UI feature enabled
        ///     2. Multiple auth options available (including external)
        /// </summary>
        /// <param name="driver"></param>
        static void HintIdpSignOn_WithOptions_Password_ChangeUser(IWebDriver driver, TaskConfiguration configuration)
        {
            // Perform UI Operations
            IdpPageTasks.GoToIdpSignOnPageWithLoginHint(driver, configuration);
            IdpPageTasks.ClickSignInOnIdpPage(driver, configuration);
            PaginatedFormsTasks.OptionsPageBackNavigate(driver, configuration);
            FormsPageTasks.ClearUsername(driver, configuration);
            FormsPageTasks.EnterCorrectUsername(driver, configuration);
            OptionsPageTasks.SelectFormsOnOptionPage(driver, configuration);
            FormsPageTasks.EnterCorrectPassword(driver, configuration);

            // Perform test validation
            var success = IdpPageTasks.ValidateSignedIn(driver, configuration);

            Debug.Assert(success);

            // Cleanup
            driver.Quit();
        }
Example #20
0
        /// <summary>
        /// ENVIRONMENT REQUIREMENTS:
        ///     1. Paginated UI feature enabled
        ///     2. Only forms auth options available
        /// </summary>
        /// <param name="driver"></param>
        static void BasicIdpSignOn_NoOptions_Password(IWebDriver driver, TaskConfiguration configuration)
        {
            // Perform UI Operations
            IdpPageTasks.GoToIdpSignOnPage(driver, configuration);
            IdpPageTasks.ClickSignInOnIdpPage(driver, configuration);
            FormsPageTasks.EnterMisformattedUsername(driver, configuration);
            FormsPageTasks.EnterCorrectUsername(driver, configuration);
            PaginatedFormsTasks.PasswordPageBackNavigate(driver, configuration);
            PaginatedFormsTasks.UsernamePageForwardNavigate(driver, configuration);
            FormsPageTasks.EnterCorrectPassword(driver, configuration);

            // Perform test validation
            var success = IdpPageTasks.ValidateSignedIn(driver, configuration);

            Debug.Assert(success);

            // Cleanup
            driver.Quit();
        }
Example #21
0
        /// <summary>
        /// ENVIRONMENT REQUIREMENTS:
        ///     1. Paginated UI feature enabled
        ///     2. Multiple auth options available (including certificate)
        /// </summary>
        /// <param name="driver"></param>
        static void BasicIdpSignOn_WithOptions_CertThenForms(IWebDriver driver, TaskConfiguration configuration)
        {
            // Perform UI Operations
            IdpPageTasks.GoToIdpSignOnPage(driver, configuration);
            IdpPageTasks.ClickSignInOnIdpPage(driver, configuration);
            FormsPageTasks.EnterMisformattedUsername(driver, configuration);
            FormsPageTasks.EnterCorrectUsername(driver, configuration);
            OptionsPageTasks.SelectCertOnOptionPage(driver, configuration);
            OptionsPageTasks.SignInWithOtherOptions(driver, configuration);
            OptionsPageTasks.SelectFormsOnOptionPage(driver, configuration);
            FormsPageTasks.EnterCorrectPassword(driver, configuration);

            // Perform test validation
            var success = IdpPageTasks.ValidateSignedIn(driver, configuration);

            Debug.Assert(success);

            // Cleanup
            driver.Quit();
        }
Example #22
0
 public static void GoToIdpSignOnPageWithLoginHint(IWebDriver driver, TaskConfiguration config)
 {
     driver.Navigate().GoToUrl($"https://{config.Farm.FarmName}/adfs/ls/idpinitiatedsignon?login_hint={config.User.CorrectUsername}");
     LogAndScreenshot(driver, config);
 }
Example #23
0
        private static void InvokeTests(Dictionary <MethodInfo, List <DesiredCapabilities> > driversPerTest, TaskConfiguration config)
        {
            foreach (var test in driversPerTest.Keys)
            {
                foreach (var driverData in driversPerTest[test])
                {
                    IWebDriver driver      = DriverFactory.GenerateDriver(driverData);
                    string     sessionName = ( string )driverData.GetCapability("name");
                    string     buildName   = ( string )driverData.GetCapability("build");

                    try
                    {
                        Console.WriteLine($"Executing test: {test.Name}");
                        test.Invoke(null, new object[] { driver, config });
                        BrowserStackLogReader.MarkTest(BrowserStackLogReader.GetSessionId(buildName, sessionName), TestStatus.Passed);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception thrown during test execution.");
                        Console.WriteLine(e.Message);
                        Console.WriteLine(e.StackTrace);
                        BrowserStackLogReader.MarkTest(BrowserStackLogReader.GetSessionId(buildName, sessionName), TestStatus.Failed);
                        driver.Quit();
                    }
                }
            }
        }
Example #24
0
        public static void ClearUsername(IWebDriver driver, TaskConfiguration config)
        {
            IWebElement usernameField = driver.FindElement(By.Id("userNameInput"));

            usernameField.Clear();
        }