Esempio n. 1
0
        public void TweetPostSuccessfull(FBPostData  TData)
        {
            string currentExecutingMethod = Utilities.GetCurrentMethod();
            var resultsWriter = new ResultsWriter(Constants.ParameterizedTest, currentExecutingMethod, true);
            var TweetTestData = FBPostData.GetTweetTestCases();

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

                if (TweetTestData != null)
                {
                    ResultReport testResultReport = new ResultReport();
                    string testFixtureName = Utilities.GenerateTestFixtureName(this.GetType(), currentExecutingMethod,
                    currentWebBrowserString);
                    testResultReport.StartMethodTimerAndInitiateCurrentTestCase(testFixtureName, true);
                    try
                    {

                        FBLoginPageFlow loginPageflow = new FBLoginPageFlow(driver);
                        FBProfilePageFlow profilePageFlow = loginPageflow.LogIn(TData.UserName, TData.Password);

                        //TwitterProfilePageFlow profilePageflow = new TwitterProfilePageFlow(driver);
                        profilePageFlow.Post(TData.Message);

                        testAsserter.AddBooleanAssert(
                         new Action<bool, string>(Assert.IsTrue),
                            profilePageFlow.VerifyPost(TData.Message),

                            Utilities.CombineTestOutcomeString(Constants.SuccessfulLegalEntityCreation, TData.Message));

                        testResultReport.SetCurrentTestCaseOutcome(true, testAsserter.AssertionCount.ToString());
                    }
                    catch (Exception e)
                    {
                        string screenShotIdentifier = String.Format("{0} - {1}", TData.Message, currentExecutingMethod);
                        //string screenShotIdentifier = String.Format("{0} - {1}", posts.PostedTweet, currentExecutingMethod);
                        base.HandleException(e, screenShotIdentifier, driver, testResultReport, testAsserter, resultsWriter);
                        Assert.Fail("***** TwitterLoginSuccessful Failed *****");
                    }
                    finally
                    {
                        testResultReport.StopMethodTimerAndFinishCurrentTestCase();
                        base.TestCases.Add(testResultReport.currentTestCase);
                    }
                }
            });

            resultsWriter.WriteResultsToFile(this.GetType().Name, TestCases);
        }
Esempio n. 2
0
        public void TweetMessage(TweetMessageData 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);
                    String message = data.message + DateTime.Now.ToString("hh:mm:ss");
                    homePageFlow.tweetMessage(message);
                    Thread.Sleep(5000);

                    testAsserter.AddBooleanAssert(
                        new Action<bool, string>(Assert.IsTrue),
                        homePageFlow.verifyMessage(message),
                        Utilities.CombineTestOutcomeString(Constants.SuccessfulTweetPost, message));
                    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("***** Post Tweet Failed *****");
                }
                finally
                {
                    testResultReport.StopMethodTimerAndFinishCurrentTestCase();
                    base.TestCases.Add(testResultReport.currentTestCase);
                }
            });

            resultsWriter.WriteResultsToFile(this.GetType().Name, TestCases);
        }
Esempio n. 3
0
 protected void HandleException(
     Exception ex,
     string screenshotIdentifier, 
     IWebDriver webDriver,
     ResultReport resultReport, 
     TestCaseAsserts asserts, 
     ResultsWriter writer)
 {
     ScreenShotImage.CaptureScreenShot(
                     webDriver,
                     Utilities.CombineTestOutcomeString(Constants.ScreenshotError, screenshotIdentifier));
     resultReport.SetCurrentTestCaseOutcome(
         false,
         asserts.AssertionCount.ToString(),
         ex.Message,
         ex.StackTrace);
     resultReport.StopMethodTimerAndFinishCurrentTestCase();
     this.TestCases.Add(resultReport.currentTestCase);
     writer.WriteResultsToFile(this.GetType().Name, TestCases);
 }