Beispiel #1
0
        public void LoginTwitter(LoginData data)
        {
            string currentExecutingMethod = Utilities.GetCurrentMethod();
            var resultsWriter = new ResultsWriter(Constants.ParameterizedTest, currentExecutingMethod, true);
            //var loginTestData = FBLoginData.GetLoginTestCases();

            Parallel.ForEach(WebDrivers, (driver, loopState) =>
            {
                var testAsserter = new TestCaseAsserts();
                string currentWebBrowserString = Utilities.GetWebBrowser(driver);
                //FBLoginData data = Utilities.GetBrowserBasedLoginCredentials(driver);

                ResultReport testResultReport = new ResultReport();
                string testFixtureName = Utilities.GenerateTestFixtureName(this.GetType(), currentExecutingMethod,
                currentWebBrowserString);
                testResultReport.StartMethodTimerAndInitiateCurrentTestCase(testFixtureName, true);
                try
                {
                    LoginPageFlow loginPageflow = new LoginPageFlow(driver);
                    HomePageFlow homePageFlow = loginPageflow.login(data.username, data.password);

                    testAsserter.AddBooleanAssert(
                        new Action<bool, string>(Assert.IsTrue),
                        homePageFlow.userLoggedIn(data.expectedResult),
                        Utilities.CombineTestOutcomeString(Constants.SuccessfulUserLogin, data.expectedResult));
                    testResultReport.SetCurrentTestCaseOutcome(true, testAsserter.AssertionCount.ToString());
                }
                catch (Exception e)
                {
                    string screenShotIdentifier = String.Format("{0} - {1}", data.username, currentExecutingMethod);
                    base.HandleException(e, screenShotIdentifier, driver, testResultReport, testAsserter, resultsWriter);
                    Assert.Fail("***** LoginTwitter Failed *****");
                }
                finally
                {
                    testResultReport.StopMethodTimerAndFinishCurrentTestCase();
                    base.TestCases.Add(testResultReport.currentTestCase);
                }
            });

            resultsWriter.WriteResultsToFile(this.GetType().Name, TestCases);
        }