public void should_add_steps() { var step = new TestStep(); _plan.AddStep(step); _plan.Steps.ShouldContain(step); }
public void Can_Navigate() { using (var driver = new ChromeDriver()) { var step = new TestStep {Value = "http://play.joljet.net"}; var navigate = new NavigateCommand(step); navigate.SetDriver(driver); navigate.Execute(); } }
public void Navigate_bad_url() { using (var driver = new ChromeDriver()) { var step = new TestStep {Value = "testing something"}; var navigate = new NavigateCommand(step); navigate.SetDriver(driver); Exception ex = Assert.Throws<UriFormatException>(() => navigate.Execute()); } }
private TestStep GetStepAt(int row, ExcelWorksheet sheet) { var testStep = new TestStep { Action = sheet.Cells["B" + row].GetValue<string>(), Property = new Element(sheet.Cells["E" + row].GetValue<string>()), Value = sheet.Cells["D" + row].GetValue<string>(), Target = sheet.Cells["C" + row].GetValue<string>() }; return testStep; }
/// <summary> /// Inserts the test step information to the test case. /// </summary> /// <param name="testStepToInsert">The test step to be insert.</param> /// <param name="selectedIndex">Index of the selected test step.</param> /// <param name="skipShared">if set to <c>true</c> [skip shared].</param> /// <returns> /// new selected index /// </returns> public int InsertTestStepInTestCase(TestStep testStepToInsert, int selectedIndex, bool skipShared = true) { if (!skipShared) { selectedIndex = this.FindNextNotSharedStepIndex(selectedIndex); } // If you delete first step and call redo operation, the step should be inserted at the beginning if (selectedIndex == -2) { log.InfoFormat("Insert test step ActionTitle= {0}, ActionExpectedResult= {1}, index= {2}", testStepToInsert.ActionTitle, testStepToInsert.ActionExpectedResult, 0); this.ObservableTestSteps.Insert(0, testStepToInsert); } else if (selectedIndex != -1) { this.ObservableTestSteps.Insert(selectedIndex + 1, testStepToInsert); log.InfoFormat("Insert test step ActionTitle= {0}, ActionExpectedResult= {1}, index= {2}", testStepToInsert.ActionTitle, testStepToInsert.ActionExpectedResult, selectedIndex + 1); } else { this.ObservableTestSteps.Add(testStepToInsert); selectedIndex = this.ObservableTestSteps.Count - 1; log.InfoFormat("Insert test step ActionTitle= {0}, ActionExpectedResult= {1}, end of test case", testStepToInsert.ActionTitle, testStepToInsert.ActionExpectedResult); } UndoRedoManager.Instance().Push((r, i) => this.RemoveTestStepFromObservableCollection(r, i), testStepToInsert, selectedIndex); TestStepManager.UpdateGenericSharedSteps(this.ObservableTestSteps); return selectedIndex; }
public TypeCommand(TestStep testStep) : base(testStep) { }
public void AddMemberRewards_Positive(MemberModel testMember, IHertzProgram program) { MemberController memController = new MemberController(Database, TestStep); TxnHeaderController txnController = new TxnHeaderController(Database, TestStep); List <TxnHeaderModel> txnList = new List <TxnHeaderModel>(); int daysAfterCheckOut = 1; DateTime checkOutDt = new DateTime(2020, 01, 31); DateTime checkInDt = checkOutDt.AddDays(daysAfterCheckOut); DateTime origBkDt = checkOutDt; RewardController rewardController = new RewardController(Database, TestStep); RewardDefModel reward = rewardController.GetRandomRewardDef(program); decimal points = reward.HOWMANYPOINTSTOEARN; long pointeventid = 6263265; try { TestStep.Start("Assing Member unique LoyaltyIds for each virtual card", "Unique LoyaltyIds should be assigned"); testMember = memController.AssignUniqueLIDs(testMember); TestStep.Pass("Unique LoyaltyIds assigned", testMember.VirtualCards.ReportDetail()); string loyaltyID = testMember.VirtualCards[0].LOYALTYIDNUMBER; string alternateID = testMember.ALTERNATEID; string vckey = testMember.VirtualCards[0].VCKEY.ToString(); TestStep.Start($"Make AddMember Call", $"Member with LID {loyaltyID} should be added successfully and member object should be returned"); MemberModel memberOut = memController.AddMember(testMember); AssertModels.AreEqualOnly(testMember, memberOut, MemberModel.BaseVerify); TestStep.Pass("Member was added successfully and member object was returned", memberOut.ReportDetail()); if (program.EarningPreference == HertzLoyalty.GoldPointsRewards.EarningPreference) { TestStep.Start($"Make UpdateMember Call", $"Member should be updated successfully and earn {points} points"); TxnHeaderModel txn = TxnHeaderController.GenerateTransaction(loyaltyID, checkInDt, checkOutDt, origBkDt, null, program, null, "US", points, null, null, "N", "US", null); txnList.Add(txn); testMember.VirtualCards[0].Transactions = txnList; MemberModel updatedMember = memController.UpdateMember(testMember); txnList.Clear(); Assert.IsNotNull(updatedMember, "Expected non null Member object to be returned"); TestStep.Pass("Member was successfully updated"); } else //Dollar and Thrifty Members Cannot be updated with the UpdateMember API so we use the HertzAwardLoyatlyCurrency API instead { TestStep.Start($"Make AwardLoyaltyCurrency Call", $"Member should be updated successfully and earn {points} points"); HertzAwardLoyaltyCurrencyResponseModel currencyOut = memController.HertzAwardLoyaltyCurrency(loyaltyID, "oagwuegbo", points, pointeventid, "Automated Appeasement", null); decimal pointsOut = memController.GetPointSumFromDB(loyaltyID); Assert.AreEqual(points, pointsOut, "Expected points and pointsOut values to be equal, but the points awarded to the member and the point summary taken from the DB are not equal"); Assert.AreEqual(currencyOut.CurrencyBalance, points, "Expected point value put into AwardLoyaltyCurrency API Call to be equal to the member's current balance, but the point values are not equal"); TestStep.Pass("Points are successfully awarded"); } TestStep.Start("Make AddMemberReward Call", "AddMemberReward Call is successfully made"); AddMemberRewardsResponseModel rewardResponse = memController.AddMemberReward(loyaltyID, reward.CERTIFICATETYPECODE, testMember.MemberDetails.A_EARNINGPREFERENCE); Assert.IsNotNull(rewardResponse, "Expected populated AddMemberRewardsResponse object from AddMemberRewards call, but AddMemberRewardsResponse object returned was null"); TestStep.Pass("Reward is added."); TestStep.Start("Validate that Member has Reward", "Member is found with Reward"); IEnumerable <MemberRewardsModel> membersRewardOut = memController.GetMemberRewardsFromDB(memberOut.IPCODE, rewardResponse.MemberRewardID); Assert.IsNotNull(membersRewardOut, "Expected populated MemberRewards object from query, but MemberRewards object returned was null"); Assert.Greater(membersRewardOut.Count(), 0, "Expected at least one MemberReward to be returned from query"); TestStep.Pass("Member Reward Found"); } catch (LWServiceException ex) { TestStep.Fail(ex.Message, new[] { $"Error Code: {ex.ErrorCode}", $"Error Message: {ex.ErrorMessage}" }); Assert.Fail(); } catch (AssertModelEqualityException ex) { TestStep.Fail(ex.Message, ex.ComparisonFailures); Assert.Fail(); } catch (Exception ex) { TestStep.Abort(ex.Message); Assert.Fail(); } }
public void BTA_35_LN_CreatePromotion_With_Certificates_And_Generate_Promotion() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); string stepName = ""; try { #region var navigator_PromotionPage = new Navigator_PromotionsPage(DriverContext); Promotions promotions = new Promotions(); NonAdminUserData promotion = new NonAdminUserData(DriverContext); promotions.StartDate = DateHelper.GetDate("Current"); promotions.EndDate = DateHelper.GetDate("Future"); string CertNumberFormat = promotion.CertNumberFormat; #endregion #region Step1:Launch Navigator Portal stepName = "Launch Navigator URL"; testStep = TestStepHelper.StartTestStep(testStep); var navigator_LoginPage = new Navigator_LoginPage(DriverContext); navigator_LoginPage.LaunchNavigatorPortal(login.Url, out string LaunchMessage); testStep.SetOutput(LaunchMessage); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step2:Login As User Admin User stepName = "Login As User Admin User and Navigate to Home page by selecting Organization and Environment"; testStep = TestStepHelper.StartTestStep(testStep); login.UserName = NavigatorUsers.NonAdminUser; login.Password = NavigatorUsers.NavigatorPassword; navigator_LoginPage.Login(login, Users.AdminRole.USER.ToString(), out string stroutput); testStep.SetOutput(stroutput); var navigator_UsersHomePage = new Navigator_UsersHomePage(DriverContext); navigator_UsersHomePage.Navigator_Users_SelectOrganizationEnvironment(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region stepName3:"Create Targeted Promotion"; stepName = "Create Targeted Promotion"; testStep = TestStepHelper.StartTestStep(testStep); promotions.Code = RandomDataHelper.RandomString(3); promotions.Name = promotion.PromotionName + RandomDataHelper.RandomString(5); promotions.Description = "value for" + promotions.Name; string enrollmentType = Navigator_PromotionsPage.EnrollmentTypes.None.ToString(); testStep.SetOutput(navigator_PromotionPage.Create_Promotions(Navigator_PromotionsPage.PromotionTypes.Targeted.ToString(), promotions, enrollmentType)); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step4: Search promotion and Generate Certificate for Promotion stepName = "Search promotion and Generate Certificate for Promotion"; testStep = TestStepHelper.StartTestStep(testStep); navigator_PromotionPage.SearchPromotion(promotions.Name, "Name"); testStep.SetOutput(navigator_PromotionPage.GeneratePromotionCertificatesAndVerify(CertNumberFormat, 10, promotions.StartDate, promotions.EndDate)); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region stepName5:"Logout from USER page"; stepName = "Logout from USER page"; testStep = TestStepHelper.StartTestStep(testStep); navigator_LoginPage.Logout(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); testCase.SetStatus(true); #endregion } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB")); testStep.SetOutput(e.Message); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); testCase.SetImageContent(DriverContext.TakeScreenshot().ToString()); Assert.Fail(); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void GetStepByTypeForTestStep() { TestStep step = TestStep.GetStepByType <TestStep> (_standAloneStep); Assert.That(step, Is.SameAs(_standAloneStep)); }
/// <summary> /// Creates the new test step. /// </summary> /// <param name="testBase">The test case.</param> /// <param name="stepTitle">The step title.</param> /// <param name="expectedResult">The expected result.</param> /// <param name="testStepGuid">The unique identifier.</param> /// <returns>the test step object</returns> public static TestStep CreateNewTestStep(ITestBase testBase, string stepTitle, string expectedResult, Guid testStepGuid) { ITestStep testStepCore = testBase.CreateTestStep(); testStepCore.ExpectedResult = expectedResult; testStepCore.Title = stepTitle; if (testStepGuid == default(Guid)) { testStepGuid = Guid.NewGuid(); } TestStep testStepToInsert = new TestStep(false, string.Empty, testStepGuid, testStepCore); return testStepToInsert; }
public void Demo_Registration_Success() { TestStep.Execute( () => { PageObjects.RegistrationPage.RegisterLinkClick(); }, 1, @"User Clicks on Registration Link", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterFirstName(); }, 2, @"User enters First name", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterLastName(); }, 3, @"User enters Last name", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterPhone(); }, 4, @"User enters Phone number", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterEMail(); }, 5, @"User enters Email", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterAddress1(); }, 6, @"User enters Address 1", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterAddress2(); }, 7, @"User enters Address 2", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterCity(); }, 8, @"User enters City", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterState(); }, 9, @"User enters State", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterPostCode(); }, 10, @"User enters Postcode", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterCountry(); }, 11, @"User selects Country", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterUserName(); }, 12, @"User enters Username", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterPassword(); }, 13, @"User enters Password", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoEnterConfirmPassword(); }, 14, @"User enters Confirm Password", ScreenCapture.Accept); TestStep.Execute( () => { PageObjects.RegistrationPage.DemoRegSubmit(); }, 8, @"User Submits the form", ScreenCapture.Accept); }
public void Execute(DriverManager driver, TestStep step) { VerifyError err = new VerifyError(); long order = step.Order; Random random = new Random(); string wait = step.Wait != null ? step.Wait : ""; string sport = step.Data; string activeTeam; int total = 0; int size = 0; string explore = ""; bool shown = false; string teamSelector = ""; List <TestStep> steps = new List <TestStep>(); if (step.Name.Equals("Verify Teams by Sport")) { steps.Add(new TestStep(order, "Click Sport Menu Open", "", "click", "xpath", "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'entity-list')][div[div[contains(.,'" + sport + "')]]]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); var teams = driver.FindElements("xpath", "//div[contains(@class,'explore-basic-rows')]//a"); for (int i = 0; i < teams.Count; i++) { int counter = i + 1; activeTeam = driver.FindElement("xpath", "(//div[contains(@class,'explore-basic-rows')]//a)[" + counter + "]").GetAttribute("innerText"); if (activeTeam.Equals("NFL")) { activeTeam = "NATIONAL FOOTBALL LEAGUE"; } steps.Add(new TestStep(order, "Click Team Name", "", "click", "xpath", "(//div[contains(@class,'explore-basic-rows')]//a)[" + counter + "]", wait)); steps.Add(new TestStep(order, "Verify Team Name in Header", activeTeam.ToUpper(), "verify_value", "xpath", "//div[contains(@class,'entity-header')]//div[contains(@class,'entity-title')]//span", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); if (i < teams.Count - 1) { steps.Add(new TestStep(order, "Click Explore", "", "click", "xpath", "//a[contains(@class,'explore-link')]", wait)); steps.Add(new TestStep(order, "Click Sport Menu Open", "", "click", "xpath", "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'entity-list')][div[div[contains(.,'" + sport + "')]]]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } } else if (step.Name.Equals("Verify MLB Teams")) { total = driver.FindElements( "xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))]").Count; for (int t = 1; t <= total; t++) { DataManager.CaptureMap["MLB_TEAM"] = driver.FindElement("xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))][" + t + "]").Text.ToUpper(); steps.Add(new TestStep(order, "Click Team " + t, "", "click", "xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))][" + t + "]", wait)); steps.Add(new TestStep(order, "Template for Team " + t, "", "run_template", "xpath", "MLB_Team", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else if (step.Name.Equals("Verify NBA Teams")) { total = driver.FindElements( "xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))]").Count; for (int t = 1; t <= total; t++) { DataManager.CaptureMap["NBA_TEAM"] = driver.FindElement("xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))][" + t + "]").Text.ToUpper(); steps.Add(new TestStep(order, "Click Team " + t, "", "click", "xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))][" + t + "]", wait)); steps.Add(new TestStep(order, "Template for Team " + t, "", "run_template", "xpath", "NBA_Team", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else if (step.Name.Equals("Click Entity by Data")) { steps.Add(new TestStep(order, "Click " + step.Data, "", "click", "xpath", "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'entity-list-row-container')][div[contains(.,'" + step.Data + "')]]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Contains("Capture") && step.Name.Contains("Random Conference")) { teamSelector = "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'entity-list-row-container') and not(contains(@class,'header'))]"; total = driver.FindElements("xpath", teamSelector).Count; total = random.Next(1, total + 1); steps.Add(new TestStep(order, "Capture Randomized Conference", "RANDOM_CONF", "capture", "xpath", "(" + teamSelector + ")[" + total + "]", wait)); // click as well if (step.Name.Contains("Click")) { steps.Add(new TestStep(order, "Click Randomized Conference", "", "click", "xpath", "(" + teamSelector + ")[" + total + "]", wait)); } TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); DataManager.CaptureMap["RANDOM_CONF_UP"] = DataManager.CaptureMap["RANDOM_CONF"].ToUpper(); } else if (step.Name.Contains("Capture") && step.Name.Contains("Random Team")) { teamSelector = "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[@class='entity-list-row-container']"; total = driver.FindElements("xpath", teamSelector).Count; total = random.Next(1, total + 1); steps.Add(new TestStep(order, "Capture Randomized Team", "RANDOM_TEAM", "capture", "xpath", "(" + teamSelector + ")[" + total + "]", wait)); // click as well if (step.Name.Contains("Click")) { steps.Add(new TestStep(order, "Click Randomized Team", "", "click", "xpath", "(" + teamSelector + ")[" + total + "]", wait)); } TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); DataManager.CaptureMap["RANDOM_TEAM_UP"] = DataManager.CaptureMap["RANDOM_TEAM"].ToUpper(); } else if (step.Name.Contains("Capture") && step.Name.Contains("Random Player")) { teamSelector = "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[@class='entity-list-row-container']"; total = driver.FindElements("xpath", teamSelector).Count; total = random.Next(1, total + 1); steps.Add(new TestStep(order, "Capture Randomized Player", "RANDOM_PLAYER", "capture", "xpath", "(" + teamSelector + ")[" + total + "]", wait)); // click as well if (step.Name.Contains("Click")) { steps.Add(new TestStep(order, "Click Randomized Player", "", "click", "xpath", "(" + teamSelector + ")[" + total + "]", wait)); } TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); DataManager.CaptureMap["RANDOM_PLAYER_UP"] = DataManager.CaptureMap["RANDOM_PLAYER"].ToUpper(); } else if (step.Name.Equals("Click Explore")) { while (!shown && size++ < 3) { explore = "//a[contains(@class,'explore-link')]"; steps.Add(new TestStep(order, "Click Explore", "", "click", "xpath", explore, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); explore = driver.FindElement("xpath", "//div[@id='ssrExploreApp']").GetAttribute("style"); log.Info("Style: " + explore); if (explore.Equals("display: none;")) { shown = false; } else { shown = true; } Thread.Sleep(0500); } } else { throw new Exception("Test Step not found in script"); } }
public void GetStepByTypeForWxeFunction() { WxeFunction step = TestStep.GetStepByType <WxeFunction> (_nestedLevel2FunctionStep); Assert.That(step, Is.SameAs(_nestedLevel2Function)); }
public void CreateTestStepThrowsError() { var client = CommonMethods.GetClientByRoute(TargetProcessRoutes.Route.TestSteps); var testStep = new TestStep(); }
public void BTA240_CDIS_GetAccountSummary_Positive() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); try { testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); testStep.SetOutput("IpCode: " + output.IpCode + " , Name: " + output.FirstName); Logger.Info("IpCode: " + output.IpCode + ", Name: " + output.FirstName); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding points to members by posting transactions using UpdateMember method"; DateTime date = DateTime.Now.AddDays(-5); var txnHeader = cdis_Service_Method.UpdateMember_PostTransactionRequiredDate(output, date); testStep.SetOutput("The transaction header of the ID is " + txnHeader.TxnHeaderId + "and transaction amount is: " + txnHeader.TxnAmount); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get memberTier through Service"; MemberTierStruct[] memberTier = cdis_Service_Method.GetMemberTier(vc[0].LoyaltyIdNumber); testStep.SetOutput("The members tierName using GetMemberTier Method is " + memberTier[0].TierDef.Name); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Account Summary through Service"; GetAccountSummaryOut AccountSummaryOut = cdis_Service_Method.GetAccountSummary(vc[0].LoyaltyIdNumber); testStep.SetOutput("The currencybalance for the member is: " + AccountSummaryOut.CurrencyBalance); //added 5 because of welcome reward which is given to customer when he joins as per rule Assert.AreEqual((txnHeader.TxnAmount + 5).ToString(), AccountSummaryOut.CurrencyBalance.ToString(), "Expected value is" + (txnHeader.TxnAmount + 5).ToString() + "Actual value is" + AccountSummaryOut.CurrencyBalance.ToString()); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "validating the response from database"; string dbresponse = DatabaseUtility.GetLoyaltyCurrencyBalancesfromDBUsingIdSOAP(vc[0].VcKey + ""); Assert.AreEqual(AccountSummaryOut.CurrencyBalance + "", dbresponse, "Expected value is" + AccountSummaryOut.CurrencyBalance + "Actual value is" + dbresponse); Assert.AreEqual(output.MemberStatus.ToString(), AccountSummaryOut.MemberStatus, "Expected value is" + output.MemberStatus.ToString() + " and actual value is" + AccountSummaryOut.MemberStatus); Assert.AreEqual(memberTier[0].TierDef.Name, AccountSummaryOut.CurrentTierName, "Expected value is" + memberTier[0].TierDef.Name + "Actual value is" + AccountSummaryOut.CurrentTierName); testStep.SetOutput("The following are member details which have been verfiied" + ";Loyalty Currency: " + AccountSummaryOut.CurrencyBalance + ";Member status: " + AccountSummaryOut.MemberStatus + ";and MemberTier: " + AccountSummaryOut.CurrentTierName); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; ReadOnlyCollection <IWebElement> elements; string data = ""; string xpath = ""; string url = ""; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); if (step.Name.Equals("Verify Main Nav Link Values")) { string[] dataSet = { "HOME", "SCORES", "LIVE TV", "STORIES", "SEARCH", "SIGN IN", "Account" }; elements = driver.FindElements("xpath", "//ul[@class='nav']//li[contains(@class,'desktop-show')]//span[contains(@class,'nav-item-text')]"); if (dataSet.Length != elements.Count) { log.Error("Unexpected element count. Expected: [" + dataSet.Length + "] does not match Actual: [" + elements.Count + "]"); err.CreateVerificationError(step, dataSet.Length.ToString(), elements.Count.ToString()); } else { for (int i = 0; i < elements.Count; i++) { if (dataSet[i].Equals(elements[i].GetAttribute("innerText").Trim())) { log.Info("Verification Passed. Expected [" + dataSet[i] + "] matches Actual [" + elements[i].GetAttribute("innerText").Trim() + "]"); } else { log.Error("Verification FAILED. Expected: [" + dataSet[i] + "] does not match Actual: [" + elements[i].GetAttribute("innerText").Trim() + "]"); err.CreateVerificationError(step, dataSet[i], elements[i].GetAttribute("innerText").Trim()); } } } } else if (step.Name.Equals("Verify URL Contains String")) { url = driver.GetDriver().Url.ToString(); if (url.Contains(step.Data)) { log.Info("Verification Passed. Expected [" + step.Data + "]" + " can be found in Actual URL [" + url + "]"); } else { log.Error("Verification FAILED.*** Expected: [" + step.Data + "] is not within Actual URL [" + url + "]"); err.CreateVerificationError(step, step.Data, url); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else if (step.Name.Equals("Store Sport by Data")) { DataManager.CaptureMap["SPORT"] = step.Data; log.Info("Storing " + step.Data + "to capture map as SPORT..."); } else if (step.Name.Equals("Store Conference by Data")) { DataManager.CaptureMap["CONF"] = step.Data; log.Info("Storing " + step.Data + "to capture map as CONF..."); } else if (step.Name.Equals("Navigate to URL by ENV")) { log.Info("Appending " + step.Data + " to ENV URL: " + TestParameters.GLOBAL_APP_URL); url = TestParameters.GLOBAL_APP_URL + step.Data; steps.Add(new TestStep(order, "Navigate to " + url, url, "navigate_to", "", "", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Navigate to External Scorestrip by ENV")) { if (TestParameters.GLOBAL_ENV.Equals("dev")) { url = "dev-"; } else if (TestParameters.GLOBAL_ENV.Equals("stg")) { url = "stage-"; } url = "https://" + url + "statics.foxsports.com/static/orion/scorestrip/index.html"; steps.Add(new TestStep(order, "Navigate to " + url, url, "navigate_to", "", "", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Capture Window Handle")) { DataManager.CaptureMap["WINDOW_HANDLE"] = driver.GetDriver().CurrentWindowHandle; log.Info("Storing window handle as " + DataManager.CaptureMap["WINDOW_HANDLE"]); } else if (step.Name.Equals("Switch To New Tab")) { ReadOnlyCollection <string> windowHandles = driver.GetDriver().WindowHandles; log.Info("Total Count of Handles: " + windowHandles.Count); foreach (string handle in windowHandles) { log.Info("Current Handle : " + handle); if (!handle.Equals(DataManager.CaptureMap["WINDOW_HANDLE"])) { DataManager.CaptureMap["NEW_WINDOW_HANDLE"] = handle; } } driver.GetDriver().SwitchTo().Window(DataManager.CaptureMap["NEW_WINDOW_HANDLE"]); log.Info("Storing new window handle as " + DataManager.CaptureMap["NEW_WINDOW_HANDLE"] + " and switching to new window."); } else if (step.Name.Equals("Close Current Tab")) { driver.GetDriver().Close(); log.Info("Closing " + DataManager.CaptureMap["NEW_WINDOW_HANDLE"]); } else { throw new Exception("Test Step not found in script"); } }
private ScopedTimer(TestStep step) { _step = step; _timer = new Stopwatch(); }
/// <summary> /// Reinitializes the test step. /// </summary> /// <param name="currentTestStep">The current test step.</param> private static void ReinitializeTestStep(TestStep currentTestStep) { currentTestStep.ActionTitle = currentTestStep.OriginalActionTitle; currentTestStep.ActionExpectedResult = currentTestStep.OriginalActionExpectedResult; }
public SnapshotCommand(TestStep testStep) : base(testStep) { }
public void GetStepByTypeForWrongType() { TestFunctionWithInvalidSteps step = TestStep.GetStepByType <TestFunctionWithInvalidSteps> (_nestedLevel2FunctionStep); Assert.That(step, Is.Null); }
/// <summary> /// Determines whether [is initialization test step] [the specified current test step]. /// </summary> /// <param name="currentTestStep">The current test step.</param> /// <returns></returns> public static bool IsInitializationTestStep(TestStep currentTestStep) { bool isInitializationTestStep = false; //if (currentTestStep.IsShared) //{ // return isInitializationTestStep; //} Regex regexNamespaceInitializations = new Regex(RegexPatternNamespaceInitializations, RegexOptions.None); Regex regexNoNamespaceInitializations = new Regex(RegextPatternNoNamespaceInitializations, RegexOptions.None); string[] lines = currentTestStep.ActionTitle.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (string currentLine in lines) { Match m = regexNamespaceInitializations.Match(currentLine); if (m.Success) { isInitializationTestStep = true; break; } else if (regexNoNamespaceInitializations.Match(currentLine).Success) { Match matchNoNamespace = regexNoNamespaceInitializations.Match(currentLine); isInitializationTestStep = true; break; } } return isInitializationTestStep; }
public void Execute(DriverManager driver, TestStep step) { VerifyError err = new VerifyError(); long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <string> standings = new List <string>(); List <string> polls = new List <string>(); List <TestStep> steps = new List <TestStep>(); IWebElement ele; string sport = ""; string games = " GAMES "; string player = ""; string playoffs = ""; string xpath = ""; bool skip = false; int count = 0; int total = 0; int size; int upper = 0; int lower = 0; IWebElement element; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); if (step.Name.Equals("Click Pagination Link by Number")) { if (step.Data.ToUpper().Equals("LAST_PAGE")) { step.Data = driver.FindElement("xpath", "//li[span[.='...']]/following-sibling::li[1]").Text; DataManager.CaptureMap["LAST_PAGE"] = step.Data; } steps.Add(new TestStep(order, "Click " + step.Data, "", "click", "xpath", "//nav[@class='pagination']//a[text()='" + step.Data + "']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify Standings Dropdown List By Sport")) { if (DataManager.CaptureMap.ContainsKey("SPORT")) { sport = DataManager.CaptureMap["SPORT"]; } else { sport = driver.FindElement("xpath", "//div[contains(@class,'entity-title')]").Text; } size = 1; switch (sport) { case "NFL": standings.Add("DIVISION"); standings.Add("CONFERENCE"); //standings.Add("PRESEASON"); break; case "NBA": standings.Add("CONFERENCE"); standings.Add("DIVISION"); standings.Add("PRESEASON"); break; case "NHL": //standings.Add("CONFERENCE"); standings.Add("LEAGUE"); standings.Add("DIVISION"); //standings.Add("WILD CARD"); //standings.Add("PRESEASON"); break; case "MLB": standings.Add("DIVISION"); standings.Add("WILD CARD"); //standings.Add("SPRING TRAINING"); break; case "ACC FOOTBALL": case "BIG 12 FOOTBALL": case "BIG TEN FOOTBALL": case "PAC-12 FOOTBALL": case "SEC FOOTBALL": standings.Add("CONFERENCE"); break; default: standings.Add(""); standings.Add(""); standings.Add(""); break; } foreach (string s in standings) { steps.Add(new TestStep(order, "Verify Dropdown Value " + size, standings[size - 1], "verify_value", "xpath", "//div[contains(@class,'standings')]//ul//li[contains(@class,'dropdown')][" + size + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); size++; } } else if (step.Name.Equals("Verify Count of Teams")) { sport = step.Data; bool success = Int32.TryParse(sport, out total); if (!success) { switch (sport) { case "NFL": sport = "32"; break; case "NBA": sport = "30"; break; case "NHL": sport = "31"; break; case "MLB": sport = "30"; break; case "BIG TEN FOOTBALL": case "SEC FOOTBALL": sport = "14"; break; case "ACC FOOTBALL": sport = "15"; break; case "PAC-12 FOOTBALL": sport = "12"; break; case "BIG 12 FOOTBALL": sport = "10"; break; default: sport = "32"; break; } } steps.Add(new TestStep(order, "Verify Count", sport, "verify_count", "xpath", "//div[contains(@class,'teams-list')]//a", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify Count of Conferences")) { sport = step.Data; bool success = Int32.TryParse(sport, out total); if (!success) { switch (sport) { case "NCAA FOOTBALL": sport = "23"; break; case "NCAA BASKETBALL": sport = "32"; break; default: sport = "0"; break; } } steps.Add(new TestStep(order, "Verify Count", sport, "verify_count", "xpath", "//div[contains(@class,'teams-list')]//a", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify Number of Player Stats Categories") || step.Name.Equals("Verify Number of Team Stats Categories")) { sport = step.Data; player = step.Data; bool success = Int32.TryParse(sport, out total); if (!success) { switch (sport) { case "NFL": player = "16"; sport = "11"; break; case "NBA": player = "8"; sport = "8"; break; case "NHL": player = "10"; sport = "7"; break; case "MLB": player = "15"; sport = "14"; break; case "NCAA FOOTBALL": case "ACC FOOTBALL": case "BIG 12 FOOTBALL": case "BIG TEN FOOTBALL": case "PAC-12 FOOTBALL": case "SEC FOOTBALL": player = "14"; sport = "9"; break; case "NCAA BASKETBALL": case "ACC BASKETBALL": case "BIG 12 BASKETBALL": case "BIG TEN BASKETBALL": case "PAC-12 BASKETBALL": case "SEC BASKETBALL": player = "13"; sport = "15"; break; default: player = ""; sport = ""; break; } } if (step.Name.Contains("Player Stats")) { steps.Add(new TestStep(order, "Verify Count", player, "verify_count", "xpath", "//div[contains(@class,'stats-overview-component')][div[.='PLAYER STATS']]//a[contains(@class,'stats-overview')]", wait)); } else if (step.Name.Contains("Team Stats")) { steps.Add(new TestStep(order, "Verify Count", sport, "verify_count", "xpath", "//div[contains(@class,'stats-overview-component')][div[.='TEAM STATS']]//a[contains(@class,'stats-overview')]", wait)); } TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify Tweet is Displayed")) { count = driver.FindElements("xpath", "//div[@class='loader']").Count; while (count != 0 && total < 5) { log.Info("Spinners found: " + count + ". Waiting for social posts to load."); Thread.Sleep(1000); count = driver.FindElements("xpath", "//div[@class='loader']").Count; total++; } steps.Add(new TestStep(order, "Verify Tweet", "", "verify_displayed", "xpath", "//*[contains(@id,'twitter-widget')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify Header Subtext")) { sport = step.Data; count = driver.FindElements("xpath", "(//div[@class='scores'])[1]//a").Count; if (count == 1) { games = " GAME "; } switch (sport) { case "NFL": DateTime NFL_season = new DateTime(2021, 08, 05); DateTime NFL_playoff = new DateTime(2022, 01, 04); if (DateTime.Now > NFL_season) { driver.FindElement("xpath", "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//span[@class='title-text']").Click(); sport = driver.FindElement("xpath", "//div[contains(@class,'week-selector') and contains(@class,'active')]//li[contains(@class,'selected')]//div[contains(@class,'week')]//div[1]").Text; player = driver.FindElement("xpath", "//div[contains(@class,'week-selector') and contains(@class,'active')]//li[contains(@class,'selected')]//div[contains(@class,'week')]//div[2]").Text; //sport = driver.FindElement("xpath","//div[contains(@class,'date-picker-container') and @style]//span[@class='title-text']").Text; } else { skip = true; } if (sport.StartsWith("PRE")) { sport = sport.Replace("PRE", "PRESEASON"); } if (DateTime.Now > NFL_playoff) { //playoffs = "S"; //playoffs = " WEEK"; } sport = sport + playoffs + ": " + player; break; case "NCAA FOOTBALL": driver.FindElement("xpath", "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//span[@class='title-text']").Click(); sport = driver.FindElement("xpath", "//div[contains(@class,'week-selector') and contains(@class,'active')]//li[contains(@class,'selected')]//div[contains(@class,'week')]//div[1]").Text; player = driver.FindElement("xpath", "//div[contains(@class,'week-selector') and contains(@class,'active')]//li[contains(@class,'selected')]//div[contains(@class,'week')]//div[2]").Text; sport = sport + ": " + player; break; case "NCAA BASKETBALL": driver.FindElement("xpath", "//div[contains(@class,'group-selector')]//a[contains(@class,'title')]").Click(); driver.FindElement("xpath", "//a[.='DI']").Click(); sport = driver.FindElement("xpath", "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//span[@class='title-text']").Text; count = driver.FindElements("xpath", "(//div[@class='scores'])[1]//a").Count; sport = count + games + sport; break; case "NBA": DateTime NBA_season = new DateTime(2021, 1, 01); DateTime NBA_playoff = new DateTime(2021, 7, 30); if (DateTime.Now > NBA_season) { sport = driver.FindElement("xpath", "//div[contains(@class,'date-picker-container') and @style]//span[@class='title-text']").Text; } else { skip = true; } if (DateTime.Now > NBA_playoff) { playoffs = "PLAYOFFS: "; } sport = playoffs + count + games + sport; break; case "NHL": DateTime NHL_season = new DateTime(2021, 01, 12); DateTime NHL_playoff = new DateTime(2021, 05, 30); if (DateTime.Now > NHL_season) { sport = driver.FindElement("xpath", "//div[contains(@class,'date-picker-container') and @style]//span[@class='title-text']").Text; } else { skip = true; } if (DateTime.Now > NHL_playoff) { playoffs = "PLAYOFFS: "; } sport = count + games + sport; break; case "MLB": DateTime MLB_season = new DateTime(2021, 4, 01); DateTime MLB_playoff = new DateTime(2021, 10, 04); if (DateTime.Now > MLB_season) { sport = driver.FindElement("xpath", "//div[contains(@class,'date-picker-container') and @style]//span[@class='title-text']").Text; } else { skip = true; } if (DateTime.Now > MLB_playoff) { playoffs = "PLAYOFFS: "; } sport = playoffs + count + games + sport; break; default: break; } if (!skip) { steps.Add(new TestStep(order, "Verify Text", sport, "verify_value", "xpath", "//div[contains(@class,'entity-header')]/div/span", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else { log.Info("No subtext current for Out of Season sports. Skipping..."); } } else if (step.Name.Equals("Capture Number of Players")) { total = driver.FindElements("xpath", "(//div[@class='table-roster'])[1]//tbody//tr").Count; log.Info("Storing total as " + total.ToString()); DataManager.CaptureMap["PLAYER_COUNT"] = total.ToString(); } else if (step.Name.Equals("Verify Polls Dropdown List")) { polls.Add("ASSOCIATED PRESS"); polls.Add("USA TODAY COACHES POLL"); size = 1; foreach (string s in polls) { steps.Add(new TestStep(order, "Verify Polls List " + size, polls[size - 1], "verify_value", "xpath", "//div[contains(@class,'polls')]//ul//li[contains(@class,'dropdown')][" + size + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); size++; } } else if (step.Name.Equals("Click Open Standings Dropdown")) { xpath = "//div[contains(@class,'standings')]//a[contains(@class,'dropdown-title')]"; ele = driver.FindElement("xpath", xpath); js.ExecuteScript("window.scrollTo(0,0);"); steps.Add(new TestStep(order, "Click Open Standings", "", "click", "xpath", xpath, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify Number of Stories & Videos")) { try { upper = Int32.Parse(step.Data); lower = upper - 2; } catch (Exception e) { log.Error("Expected data to be a numeral. Setting data to 0."); upper = 0; } size = driver.FindElements("xpath", "//*[@class='news' or (contains(@class,'pointer-default') or contains(@class,'no') and contains(@class,'news')) or contains(@class,'video-container')]").Count; if (size >= lower && size <= upper) { log.Info("Verification Passed. " + size + " is between " + lower + " and " + upper); } else { log.Info("Verification FAILED. " + size + " is not between " + lower + " and " + upper); err.CreateVerificationError(step, "Number Between " + lower + " and " + upper.ToString(), size.ToString()); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else { throw new Exception("Test Step not found in script"); } }
/// <summary> /// Edits the test step action expected result. /// </summary> /// <param name="currentTestStep">The current test step.</param> /// <param name="newActionExpectedResult">The new action expected result.</param> public static void EditTestStepActionExpectedResult(TestStep currentTestStep, string newActionExpectedResult) { UndoRedoManager.Instance().Push((step, t) => EditTestStepActionExpectedResult(currentTestStep, t), currentTestStep, currentTestStep.OriginalActionExpectedResult, "Change the test step expected result"); log.InfoFormat("Change ActionTitle from {0} to {1}", currentTestStep.ActionExpectedResult, newActionExpectedResult); currentTestStep.ActionExpectedResult = newActionExpectedResult; currentTestStep.OriginalActionExpectedResult = newActionExpectedResult; }
public void BTA139_CSP_Member_Search() { ProjectBasePage basePages = new ProjectBasePage(driverContext); testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); string stepName = ""; bool stepstatus; try { Common common = new Common(DriverContext); #region Precondtion:Create Members CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.AddCDISMemberWithAllFields(); string LoyaltyNumber = DatabaseUtility.GetLoyaltyID(output.IpCode.ToString()); testStep.SetOutput("Generated :" + output.IpCode + ",Name:" + output.FirstName); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); #endregion #region Step1:Launch CSPortal Portal stepName = "Launch Customer Service Portal URL"; testStep = TestStepHelper.StartTestStep(testStep); var CSP_LoginPage = new CSPortal_LoginPage(DriverContext); CSP_LoginPage.LaunchCSPortal(login.Csp_url, out string Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step2:Login As csadmin stepName = "Login As csadmin User"; testStep = TestStepHelper.StartTestStep(testStep); login.UserName = CsPortalData.csadmin; login.Password = CsPortalData.csadmin_password; CSP_LoginPage.LoginCSPortal(login.UserName, login.Password, out Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step3:Search Based on Loyalty ID stepName = "Search Based on Loyalty ID"; testStep = TestStepHelper.StartTestStep(testStep); var CSPSearchPage = new CSPortal_SearchPage(DriverContext); stepstatus = CSPSearchPage.Search_BasedOnLoyaltyID(LoyaltyNumber, out Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step4:Select and Verify Loyalty ID stepName = "Select and Verify Loyalty ID"; testStep = TestStepHelper.StartTestStep(testStep); CSPSearchPage.Select(output.FirstName); var CSPAccountSummaryPage = new CSPortal_MemberAccountSummaryPage(DriverContext); stepstatus = CSPAccountSummaryPage.VerifyLoyaltyId(LoyaltyNumber, out Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step5:Search Based on Email ID stepName = "Search Based on Email ID"; var CSP_HomePage = new CSPortal_HomePage(DriverContext); CSP_HomePage.NavigateToDashBoardMenu(CSPortal_HomePage.DashBoard.MemberSearch, out stepName); testStep = TestStepHelper.StartTestStep(testStep); stepstatus = CSPSearchPage.Search_EmailID(output.PrimaryEmailAddress, out Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step6:Search Based on FirstName stepName = "Search Based on FirstName"; testStep = TestStepHelper.StartTestStep(testStep); stepstatus = CSPSearchPage.Search_FirstName(output.FirstName, out Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step7:Search Based on Last Name stepName = "Search Based on Last Name"; testStep = TestStepHelper.StartTestStep(testStep); stepstatus = CSPSearchPage.Search_LastName(output.LastName, out Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step8:Search With no Inputs stepName = "Search With no Inputs"; testStep = TestStepHelper.StartTestStep(testStep); stepstatus = CSPSearchPage.Search_WithBlankInputs(out Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step9:Logout As csadmin stepName = "Logout As csadmin"; testStep = TestStepHelper.StartTestStep(testStep); CSP_HomePage.LogoutCSPortal(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName + e, false, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); testCase.SetImageContent(DriverContext.TakeScreenshot().ToString()); Assert.Fail(); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public NavigateCommand(TestStep testStep) : base(testStep) { }
public void BTA1235_ST1301_SOAP_RedeemMemberCouponByCertNmbr_ExistingChannel() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); try { IList <JToken> JsonData = ProjectBasePage.GetJSONData("CommonSqlStatements"); string sqlstmt = (string)JsonData.FirstOrDefault()["Get_CertNumber_From_LWMemberCouponTable_With_EmptyDateRedeemed"]; Logger.Info("Test Method Started: " + testCase.GetTestCaseName()); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get a valid certificateNumber from LW_MemberCoupon table"; string validCertNumber = DatabaseUtility.GetFromSoapDB(string.Empty, string.Empty, string.Empty, "CERTIFICATENMBR", sqlstmt); testStep.SetOutput("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); Logger.Info("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Redeem the member coupon using certNumber with an existing channel"; string channel = DatabaseUtility.GetFromSoapDB("Lw_Channeldef", string.Empty, string.Empty, "NAME", string.Empty); redemptiondate = System.DateTime.Now; var certDetails = cdis_Service_Method.RedeemMemberCouponByCertNumber(validCertNumber, channel, "en", redemptiondate, timesused, false, false, string.Empty, out elapsedTime); string dbRedemptionDate = DatabaseUtility.GetFromSoapDB("LW_MEMBERCOUPON", "CERTIFICATENMBR", validCertNumber, "DATEREDEEMED", string.Empty); Assert.AreEqual(System.DateTime.Now.ToString("MM/dd/yyyy"), Convert.ToDateTime(dbRedemptionDate).ToString("MM/dd/yyyy"), "Expected value is" + System.DateTime.Now.ToString("MM/dd/yyyy") + " and Actual value is" + Convert.ToDateTime(dbRedemptionDate).ToString("MM/dd/yyyy")); testStep.SetOutput("The Coupon name from the response of RedeemMemberCouponByCertNumber method is: " + certDetails.CouponDefinition.Name + "; the redemption date is: " + dbRedemptionDate); Logger.Info("TestStep: " + stepName + " ##Passed## The Coupon name from the response of RedeemMemberCouponByCertNumber method is: " + certDetails.CouponDefinition.Name + " and; the redemption date is: " + dbRedemptionDate); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate the elapsed time is greater than Zero"; if (elapsedTime > 0) { testStep.SetOutput("Elapsed time is greater than zero and the Elapsed time is " + elapsedTime); } else { throw new Exception("Elapsed time is not greater than Zero"); } testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); //unredeem the cert again since we have less certificates cdis_Service_Method.UnRedeemMemberCouponByCertNumber(validCertNumber, out elapsedTime); Logger.Info("###Test Execution Ends### Test Passed: " + testCase.GetTestCaseName()); testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); Logger.Info("Test Failed: " + testCase.GetTestCaseName() + "Reason: " + e.Message); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void LN_32_Create_Targeted_Promotion_with_None_option() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); string stepName = ""; try { #region var navigator_PromotionPage = new Navigator_PromotionsPage(DriverContext); Promotions promotions = new Promotions(); NonAdminUserData promotion = new NonAdminUserData(DriverContext); promotions.StartDate = DateHelper.GetDate("Current"); promotions.EndDate = DateHelper.GetDate("Future"); #endregion #region stepName 1: "Open Navigator URL"; stepName = "Open Navigator URL"; var navigator_LoginPage = new Navigator_LoginPage(DriverContext); testStep = TestStepHelper.StartTestStep(testStep); navigator_LoginPage.LaunchNavigatorPortal(login.Url, out string LaunchMessage); testStep.SetOutput(LaunchMessage); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region stepName 2: "Login to Navigator using User With AllRoles"; stepName = "Login to Navigator using User With AllRoles"; testStep = TestStepHelper.StartTestStep(testStep); login.UserName = NavigatorUsers.NonAdminUser; login.Password = NavigatorUsers.NavigatorPassword; navigator_LoginPage.Login(login, Users.AdminRole.USER.ToString(), out string stroutput); testStep.SetOutput(stroutput); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region stepName 3: "Select organization and environment on USER page"; stepName = "Select organization and environment on USER page"; testStep = TestStepHelper.StartTestStep(testStep); var navigator_UsersHomePage = new Navigator_UsersHomePage(DriverContext); navigator_UsersHomePage.Navigator_Users_SelectOrganizationEnvironment(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region stepName 4:"Create Targeted Promotion With EnrollmentTypes As None"; stepName = "Create Targeted Promotion With EnrollmentTypes As None"; testStep = TestStepHelper.StartTestStep(testStep); promotions.Code = RandomDataHelper.RandomString(3); promotions.Name = promotion.PromotionName + RandomDataHelper.RandomString(5); promotions.Description = "value for" + promotions.Name; promotions.Enrollmenttype = Navigator_PromotionsPage.EnrollmentTypes.None.ToString(); testStep.SetOutput(navigator_PromotionPage.Create_Promotions(Navigator_PromotionsPage.PromotionTypes.Targeted.ToString(), promotions, promotions.Enrollmenttype)); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region stepName5: "Verify Non-Targeted Promotion Details In Grid"; stepName = "Verify Non-Targeted Promotion Details In Grid"; testStep = TestStepHelper.StartTestStep(testStep); var searchCriteria = "Name"; var result = navigator_PromotionPage.VerifyPromotionDetailsInGrid(promotions, searchCriteria, out string outMsg); testStep.SetOutput(outMsg); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, result, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region stepName 5: "Verify Targeted Promotion on Model -> Attribute Sets -> TxnHeader -> Rules Page"; stepName = "Verify Targeted Promotion on Model -> Attribute Sets -> TxnHeader -> Rules Page"; testStep = TestStepHelper.StartTestStep(testStep); result = navigator_PromotionPage.VerifyPromotionisCreatedOrNot(promotions.Code); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, result, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion . #region Step5:Get the data from DB stepName = "Searching Promotion in the LW_Promotion Table"; testStep = TestStepHelper.StartTestStep(testStep); var stepstatus = navigator_PromotionPage.VerifyPromotionDetailsInDatabese(promotions.Name, promotions.Description, promotions.Enrollmenttype, Navigator_PromotionsPage.PromotionTypes.Targeted.ToString()); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region stepName6:"Logout from USER page"; stepName = "Logout from USER page"; testStep = TestStepHelper.StartTestStep(testStep); navigator_LoginPage.Logout(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); testCase.SetStatus(true); #endregion } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); testCase.SetImageContent(DriverContext.TakeScreenshot().ToString()); Assert.Fail(); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA1235_ST1434_SOAP_RedeemMemberCouponByCertNmbr_NonExistingLanguage() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); try { IList <JToken> JsonData = ProjectBasePage.GetJSONData("CommonSqlStatements"); string sqlstmt = (string)JsonData.FirstOrDefault()["Get_CertNumber_From_LWMemberCouponTable_With_EmptyDateRedeemed"]; Logger.Info("Test Method Started: " + testCase.GetTestCaseName()); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get a valid certificateNumber from LW_MemberCoupon table"; string validCertNumber = DatabaseUtility.GetFromSoapDB(string.Empty, string.Empty, string.Empty, "CERTIFICATENMBR", sqlstmt); testStep.SetOutput("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); Logger.Info("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Redeem the member coupon with non existing language and validate the Error Code:6002"; redemptiondate = System.DateTime.Now; string language = "test"; string error = cdis_Service_Method.RedeemMemberCouponByByCertNumber_Invalid(validCertNumber, "Web", language, redemptiondate, timesused, false, false, string.Empty); if (error.Contains("Error code=6002") && error.Contains("Error Message=Specified language is not defined")) { testStep.SetOutput("The ErrorMessage from Service is received as expected. " + error); Logger.Info("The ErrorMessage from Service is received as expected. " + error); } else { throw new Exception("Error not received as expected error: 6002. Actual error received is:\"" + error + "\""); } testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); //unredeem the cert again since we have less certificates cdis_Service_Method.UnRedeemMemberCouponByCertNumber(validCertNumber, out elapsedTime); Logger.Info("###Test Execution Ends### Test Passed: " + testCase.GetTestCaseName()); testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); Logger.Info("Test Failed: " + testCase.GetTestCaseName() + "Reason: " + e.Message); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA1028_ST1172_SOAP_AssociateMemberSocialHandles_verifyElapsedTime() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; try { Logger.Info("Test Method Started"); Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); testStep.SetOutput("IpCode: " + output.IpCode + " , Name: " + output.FirstName); Logger.Info("IpCode: " + output.IpCode + ", Name: " + output.FirstName); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Associate social handles for a member"; vc = output.GetLoyaltyCards(); string msg = cdis_Service_Method.AssociateMemberSocialHandles(vc[0].LoyaltyIdNumber, providerType, providerUID, out elapsedTime); testStep.SetOutput(msg); Logger.Info(msg); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate Associate social handles for a member are added successfully"; vc = output.GetLoyaltyCards(); MemberSocialHandleStruct[] socialHandlesData = cdis_Service_Method.GetMemberSocialHandles(vc[0].LoyaltyIdNumber, out stepOutput); Assert.AreEqual(socialHandlesData[0].ProviderType, providerType, "Expected value is " + providerType + "actual value is " + socialHandlesData[0].ProviderType); Assert.AreEqual(socialHandlesData[0].ProviderUID, providerUID, "Expected value is " + providerUID + "actual value is" + socialHandlesData[0].ProviderUID); testStep.SetOutput("Social handles for a member are added successfully where loyaltyid is: " + vc[0].LoyaltyIdNumber + " ,ProviderType: " + socialHandlesData[0].ProviderType + " and ProviderUID: " + socialHandlesData[0].ProviderUID); Logger.Info("Social handles for a member are added successfully where loylaty id is: " + vc[0].LoyaltyIdNumber + "ProviderType" + socialHandlesData[0].ProviderType + " and ProviderUID" + socialHandlesData[0].ProviderUID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate the elapsed time is greater than Zero"; if (elapsedTime > 0) { testStep.SetOutput("Elapsed time is greater than zero and the actual elapsed time is " + elapsedTime); } else { throw new Exception("Elapsed time is not greater than Zero"); } testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA372_REST_UpdateMember_NEGATIVE() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); REST_Service_Methods rest_Service_Method = new REST_Service_Methods(common); JObject response; try { Logger.Info("Test Method Started"); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Updating member using invalid IPCODE"; response = (JObject)rest_Service_Method.PatchUpdateMemberwithIpcode(common.RandomNumber(12)); if (response.Value <string>("isError") == "True") { testStep.SetOutput("The response code from \"Update Member \" service for a user with " + "invalid IPCODE is: " + response.Value <int>("responseCode") + ""); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate the developer message for the above response code from the Service"; if (response.Value <int>("responseCode") == 10504) { testStep.SetOutput("developerMessage from response is: " + response.Value <string>("developerMessage")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); Logger.Info("test passed"); testCase.SetStatus(true); } else { Logger.Info("test failed"); testStep.SetOutput("response message is" + response.Value <string>("developerMessage") + "and response code is" + response.Value <int>("responseCode")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); throw new Exception("response message is" + response.Value <string>("developerMessage") + "and response code is" + response.Value <int>("responseCode")); } } else { Logger.Info("test failed"); testStep.SetOutput(response.Value <string>("developerMessage")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); throw new Exception(response.Value <string>("developerMessage")); } } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
static async Task RunAsync(TCObject objectToExecuteOn) { HttpClient client = new HttpClient(); System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return(true); }; //client.Timeout = TimeSpan.FromSeconds(10); client.BaseAddress = new Uri(ZUtil.BASE_URL); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var RELATIVE_PATH = "flex/services/rest/latest/execution/create"; String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(ZUtil.USER + ":" + ZUtil.PASSWORD)); client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded); ExecutionList executionList = (ExecutionList)objectToExecuteOn; ExecutionListItem executionListItem = (ExecutionListItem)executionList.Items.First(); ExecutionList executionEntryList = executionListItem.ExecutionList; ExecutionEntryFolder executionEntryFolder = (ExecutionEntryFolder)executionEntryList.Items.First(); List <Object> testCase = new List <Object>(); string execStatus = "-1"; for (int i = 0; i < executionEntryFolder.Items.Count(); i++) { ExecutionEntry execItem = (ExecutionEntry)executionEntryFolder.Items.ElementAt(i); ExecutionResult execResult = execItem.ActualResult; if (execResult.Equals(ExecutionResult.Passed)) { execStatus = "1"; } else { execStatus = "2"; } List <Object> testSteps = new List <Object>(); TestCase testCaseItem = (TestCase)execItem.TestCase; for (int j = 0; j < testCaseItem.Items.Count(); j++) { TestStep ts = (TestStep)testCaseItem.Items.ElementAt(j); var tsObj = new { name = ts.DisplayedName }; testSteps.Add(tsObj); } var tc = new { name = execItem.DisplayedName, executionResult = execStatus, testSteps = testSteps.ToArray() }; testCase.Add(tc); } var jsonContent = new { testCases = testCase.ToArray(), executionName = executionList.DisplayedName, releaseId = "1", folderName = executionListItem.DisplayedName }; string json = JsonConvert.SerializeObject(jsonContent); try { HttpResponseMessage response = await client.PostAsync(ZUtil.CONTEXT_PATH + RELATIVE_PATH, new StringContent(json.ToString(), Encoding.UTF8, "application/json")); response.EnsureSuccessStatusCode(); //write response in console //Console.WriteLine(response); // Deserialize the updated product from the response body. //string result = await response.Content.ReadAsStringAsync(); //write Response in console //Console.WriteLine(result); // response.Dispose(); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void BTA372_REST_UpdateMember_POSITIVE() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); REST_Service_Methods rest_Service_Method = new REST_Service_Methods(common); JObject response; try { Logger.Info("Test Method Started"); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member through rest service"; JObject member = (JObject)rest_Service_Method.PostMembergeneral(); if (member.Value <string>("isError") == "False") { testStep.SetOutput("Members details are IPCODE= " + member["data"].Value <int>("id") + "; Name= " + member["data"].Value <string>("firstName") + "; and Email=" + member["data"]["cards"][0].Value <string>("email")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); } else { testStep.SetOutput(member.Value <string>("developerMessage")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); Logger.Info("test failed"); listOfTestSteps.Add(testStep); throw new Exception(member.Value <string>("developerMessage")); } testStep = TestStepHelper.StartTestStep(testStep); stepName = "Updating Member through REST Service"; response = (JObject)rest_Service_Method.PatchUpdateMemberwithIpcode(member["data"].Value <int>("id") + ""); if (response.Value <String>("isError") == "False") { testStep.SetOutput("The Member with IPcode: " + response["data"].Value <int>("id") + " email address has been updated to : \"" + response["data"].Value <string>("email") + "\" and city from member attribute details has been updated to: \"" + response["data"]["attributeSets"][0]["memberDetails"][0].Value <string>("city") + "\""); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validating data with data from database"; string dbresponse = DatabaseUtility.GetEmailfromDBUsingIpcodeREST(response["data"].Value <int>("id")); Assert.AreEqual(response["data"].Value <string>("email"), dbresponse, "Expected value is " + response["data"].Value <string>("email") + " and actual value is " + dbresponse); string dbresponse1 = DatabaseUtility.GetCityusingIPCODEREST(response["data"].Value <int>("id")); Assert.AreEqual(dbresponse1, response["data"]["attributeSets"][0]["memberDetails"][0].Value <string>("city"), "Expected city name is" + dbresponse1 + " and the actual city name is" + response["data"]["attributeSets"][0]["memberDetails"][0].Value <string>("city")); testStep.SetOutput("Updated EMAIL-ID from database is: \"" + dbresponse + "\" and Updated city from DB is \"" + response["data"]["attributeSets"][0]["memberDetails"][0].Value <string>("city") + "\""); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); Logger.Info("test passed"); testCase.SetStatus(true); } else { Logger.Info("test failed"); testStep.SetOutput(response.Value <String>("developerMessage")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); throw new Exception(response.Value <String>("developerMessage")); } } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public SelectCommand(TestStep testStep) : base(testStep) { }
public ActionResult TestPartial(int?id) { //--- Block the transition from a direct link if (!ControllerContext.IsChildAction) { if (!Request.IsAjaxRequest() || Session["Test"] == null) { return(RedirectToAction("Test")); } } //--- //--- Add user choice to session if (id != null) { ((Test)Session["Test"]).Steps.Last().ChosenStyleId = (int)id; } //--- var result = new List <Image>(_imgInStepCount); //--- If step is last if (((Test)Session["Test"]).Steps.Count >= _stepsMaxCount) { var winners = ((Test)Session["Test"]).GetWinnersId(); if (winners.Count == 1) { Session["WinnerId"] = winners.First(); return(RedirectToAction("Result")); } //--- If styles with biggest choises more then one -> will work till style will be one else { var step = new TestStep(); for (int i = 0; i < _imgInStepCount; i++) { int styleId = winners[i]; int imageId = _GetNotShownImage(styleId); var image = _imgRepo.GetImageById(styleId, imageId); step.ShowedImages.Add(image); result.Add(image); } ((Test)Session["Test"]).Steps.Add(step); //Add new step } //--- } //--- //--- Generate two random img from different styles else { var step = new TestStep(); Random rnd = new Random(); for (int i = 0; i < _imgInStepCount; i++) { int styleId = _GetNotInListStyle(result); int imageId = _GetNotShownImage(styleId); var image = _imgRepo.GetImageById(styleId, imageId); step.ShowedImages.Add(image); result.Add(image); } ((Test)Session["Test"]).Steps.Add(step);//Add new step } //--- return(PartialView(result)); }
/// <summary> /// Removes the test step from test steps observable collection. /// </summary> /// <param name="testStepToBeRemoved">The test step to be removed.</param> /// <param name="selectedIndex">Index of the selected.</param> public void RemoveTestStepFromObservableCollection(TestStep testStepToBeRemoved, int selectedIndex) { this.ObservableTestSteps.Remove(testStepToBeRemoved); log.InfoFormat("Remove test step ActionTitle = {0}, ExpectedResult= {1}", testStepToBeRemoved.ActionTitle, testStepToBeRemoved.ActionExpectedResult); UndoRedoManager.Instance().Push((r, i) => this.InsertTestStepInTestCase(r, i), testStepToBeRemoved, selectedIndex, "remove Test Step"); TestStepManager.UpdateGenericSharedSteps(this.ObservableTestSteps); }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; int size; DateTime start; DateTime end; DateTime now; string data = ""; bool season = false; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); if (step.Name.Equals("Is Sport In-Season?")) { now = DateTime.Today; switch (step.Data) { case "CBK": start = new DateTime(2020, 11, 24); end = new DateTime(2021, 04, 05); break; case "CFB": start = new DateTime(2020, 08, 19); end = new DateTime(2021, 01, 11); break; case "Golf": case "GOLF": start = new DateTime(2021, 01, 07); end = new DateTime(2021, 09, 05); break; case "MLB": start = new DateTime(2021, 04, 01); end = new DateTime(2021, 10, 28); break; case "NASCAR": start = new DateTime(2021, 02, 09); end = new DateTime(2021, 11, 07); break; case "NBA": start = new DateTime(2020, 12, 11); end = new DateTime(2021, 08, 01); break; case "NHL": start = new DateTime(2019, 09, 15); end = new DateTime(2020, 09, 28); break; case "NFL": start = new DateTime(2020, 08, 01); end = new DateTime(2021, 02, 02); break; case "Soccer": case "SOCCER": start = new DateTime(2020, 11, 05); end = new DateTime(2021, 11, 05); break; default: start = new DateTime(2020, 11, 05); end = new DateTime(2021, 11, 05); break; } log.Info("Current date: " + now); if (now >= start && now < end) { DataManager.CaptureMap.Add("IN_SEASON", "True"); log.Info("Today is in-season. Storing IN_SEASON to Capture Map as True."); } else { DataManager.CaptureMap.Add("IN_SEASON", "False"); log.Info("Today is not in-season. Storing IN_SEASON to Capture Map as False."); } } else { throw new Exception("Test Step not found in script"); } }
public static ScopedTimer StartNew(TestStep step) { var timer = new ScopedTimer(step); timer.Start(); return timer; }
public void BTA122_CSP_CreateDifferentRoles() { ProjectBasePage basePages = new ProjectBasePage(this.driverContext); testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); bool stepstatus; string stepName = ""; #region Object Initialization var homePage = new CSPortal_HomePage(DriverContext); var userAdministrationPage = new CSPortal_UserAdministration(DriverContext); var loginPage = new CSPortal_LoginPage(DriverContext); var rolePage = new CSPortal_UserAdministration_RolePage(DriverContext); #endregion try { #region Step1:Launch CSPortal Portal stepName = "Launch Customer Service Portal URL"; testStep = TestStepHelper.StartTestStep(testStep); loginPage.LaunchCSPortal(login.Csp_url, out string Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step2:Login As csadmin stepName = "Login As csadmin User"; testStep = TestStepHelper.StartTestStep(testStep); login.UserName = CsPortalData.csadmin; login.Password = CsPortalData.csadmin_password; loginPage.LoginCSPortal(login.UserName, login.Password, out Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step3 : Navigate to User Administration testStep = TestStepHelper.StartTestStep(testStep); stepstatus = homePage.NavigateToDashBoardMenu(CSPortal_HomePage.DashBoard.UserAdministration, out stepName); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step4 : Navigate to Roles stepName = "Navigate to Roles"; testStep = TestStepHelper.StartTestStep(testStep); stepstatus = userAdministrationPage.NavigateToSectionMenu(CSPortal_UserAdministration.Menu.Roles); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step5 : Create AdminRole if it does not exists stepName = "Create AdminRole if it does not exists"; testStep = TestStepHelper.StartTestStep(testStep); var role = RoleValue.Admin; var pointAwardLimit = RoleValue.AdminRole_PointAwardLimit; stepstatus = rolePage.CreateNewRole(role, pointAwardLimit, out string stat); testStep.SetOutput(stat); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step6 : Create SrAdminRole if it does not exists stepName = "Create SrAdminRole if it does not exists"; testStep = TestStepHelper.StartTestStep(testStep); role = RoleValue.SrAdmin; pointAwardLimit = RoleValue.SrAdminRole_PointAwardLimit; stepstatus = rolePage.CreateNewRole(role, pointAwardLimit, out stat); testStep.SetOutput(stat); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step7 : Create JrAdminRole if it does not exists stepName = "Create JrAdminRole if it does not exists"; testStep = TestStepHelper.StartTestStep(testStep); role = RoleValue.JrAdmin; pointAwardLimit = RoleValue.JrAdminRole_PointAwardLimit; stepstatus = rolePage.CreateNewRole(role, pointAwardLimit, out stat); testStep.SetOutput(stat); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step8 : Logout As csadmin stepName = "Logout As csadmin"; testStep = TestStepHelper.StartTestStep(testStep); homePage.LogoutCSPortal(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); testCase.SetImageContent(DriverContext.TakeScreenshot().ToString()); Assert.Fail(); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public ClickCommand(TestStep testStep) : base(testStep) { }
private void GenerateXlsFromTestPlan(String path, List <GeneralUseStructure> listPlanStructure) { #region Styles and SLDocument SLDocument xlsx = new SLDocument(); SLStyle style = xlsx.CreateStyle(); style.SetWrapText(true); SLStyle indexStyle = xlsx.CreateStyle(); indexStyle.Alignment.Horizontal = HorizontalAlignmentValues.Right; indexStyle.SetWrapText(true); SLStyle headerStyle = xlsx.CreateStyle(); headerStyle.Fill.SetPattern(PatternValues.Solid, System.Drawing.Color.Yellow, System.Drawing.Color.Black); headerStyle.Font.Bold = true; headerStyle.Font.FontName = "Calibri"; headerStyle.Border.RightBorder.Color = System.Drawing.Color.Black; headerStyle.Border.LeftBorder.Color = System.Drawing.Color.Black; headerStyle.Border.RightBorder.BorderStyle = BorderStyleValues.Thin; headerStyle.Border.LeftBorder.BorderStyle = BorderStyleValues.Thin; headerStyle.Border.TopBorder.BorderStyle = BorderStyleValues.Thin; headerStyle.Border.BottomBorder.BorderStyle = BorderStyleValues.Thin; xlsx.DeleteWorksheet(SLDocument.DefaultFirstSheetName); #endregion #region Populate Excel foreach (GeneralUseStructure planStructure in listPlanStructure) { TestPlan testPlan = (TestPlan)planStructure; for (int k = 0; k < testPlan.TestCases.Count; k++) { TestCase testCase = testPlan.TestCases[k]; xlsx.SetColumnStyle(1, 1, style); //xlsx.SetColumnWidth(1, 1, 50); String title = testCase.Title; title = title.Replace(" ", ""); if (title.Length > 31) { title = title.Substring(0, 25) + title.Substring(title.Length - 5, 5); } xlsx.AddWorksheet(HttpUtility.UrlDecode(title)); xlsx.SelectWorksheet(title); xlsx.SetCellValue(1, 1, "Test Case #"); xlsx.SetCellValue(1, 2, "Work Item ID"); xlsx.SetCellValue(1, 3, "Test Title"); xlsx.SetCellValue(1, 4, "Summary"); xlsx.SetCellValue(1, 5, "Test Step"); xlsx.SetCellValue(1, 6, "Action/Description"); xlsx.SetCellValue(1, 7, "Expected Results"); xlsx.SetCellValue(1, 8, "Assigned To"); xlsx.SetCellValue(1, 9, "State"); xlsx.SetCellValue(1, 10, "Reason"); xlsx.SetCellValue(1, 11, "Iteration Path"); xlsx.SetCellValue(1, 12, "Area Path"); xlsx.SetCellValue(1, 13, "Application"); xlsx.SetCellValue(1, 14, "Complexity"); xlsx.SetCellValue(1, 15, "Risks"); xlsx.SetCellValue(1, 16, "TC Lifecycle"); xlsx.SetCellValue(1, 17, "Lifecycle Type"); xlsx.SetCellValue(1, 18, "TC Team Usage"); xlsx.SetCellStyle("A1", "R1", headerStyle); xlsx.SetCellValue(2, 1, "TC" + testCase.WorkItemId); xlsx.SetCellStyle(2, 1, style); xlsx.SetCellValue(2, 2, "Test Case " + HttpUtility.UrlDecode(testCase.WorkItemId.ToString())); xlsx.SetCellStyle(2, 2, style); if (k != (testPlan.TestCases.Count - 1)) { xlsx.SetCellValue(2, 3, HttpUtility.UrlDecode(testCase.Title)); xlsx.SetCellStyle(2, 3, style); } xlsx.SetCellValue(2, 4, HttpUtility.UrlDecode(testCase.Summary)); xlsx.SetCellStyle(2, 4, style); xlsx.SetCellValue(2, 5, "1"); xlsx.SetCellStyle(2, 5, indexStyle); xlsx.SetCellValue(2, 6, HttpUtility.UrlDecode(testCase.TDpreConditions)); xlsx.SetCellStyle(2, 6, style); xlsx.SetCellValue(2, 7, HttpUtility.UrlDecode(testCase.TDpostConditions)); xlsx.SetCellStyle(2, 7, style); xlsx.SetCellValue(2, 8, HttpUtility.UrlDecode(testCase.TDassigned)); xlsx.SetCellStyle(2, 8, style); xlsx.SetCellValue(2, 9, HttpUtility.UrlDecode(testCase.TDstate)); xlsx.SetCellStyle(2, 9, style); xlsx.SetCellValue(2, 10, HttpUtility.UrlDecode(testCase.TDreason)); xlsx.SetCellStyle(2, 10, style); xlsx.SetCellValue(2, 11, HttpUtility.UrlDecode(testCase.TDiterationPath)); xlsx.SetCellStyle(2, 11, style); xlsx.SetCellValue(2, 12, HttpUtility.UrlDecode(testCase.TDareaPath)); xlsx.SetCellStyle(2, 12, style); xlsx.SetCellValue(2, 13, HttpUtility.UrlDecode(testCase.TDapplication)); xlsx.SetCellStyle(2, 13, style); xlsx.SetCellValue(2, 14, HttpUtility.UrlDecode(testCase.TDcomplexity)); xlsx.SetCellStyle(2, 14, style); xlsx.SetCellValue(2, 15, HttpUtility.UrlDecode(testCase.TDrisks)); xlsx.SetCellStyle(2, 15, style); xlsx.SetCellValue(2, 16, HttpUtility.UrlDecode(testCase.TDtcLifecycle)); xlsx.SetCellStyle(2, 16, style); xlsx.SetCellValue(2, 17, HttpUtility.UrlDecode(testCase.TDlifecycleType)); xlsx.SetCellStyle(2, 17, style); xlsx.SetCellValue(2, 18, HttpUtility.UrlDecode(testCase.TDtcTeamUsage)); xlsx.SetCellStyle(2, 18, style); #region Step for (int i = 0; i < testCase.TestSteps.Count; i++) { TestStep step = testCase.TestSteps[i]; if (k == (testPlan.TestCases.Count - 1)) { xlsx.SetCellValue(i + 2, 3, HttpUtility.UrlDecode(step.Title)); xlsx.SetCellStyle(i + 2, 3, style); } if (!testCase.WriteFirstLine) { xlsx.SetCellValue(i + 2, 5, HttpUtility.UrlDecode(step.Index)); xlsx.SetCellStyle(i + 2, 5, indexStyle); if (step.Description.Contains("$@#ITERATION@#")) { String[] aux = step.Description.Split('$'); xlsx.SetCellValue(i + 2, 6, HttpUtility.UrlDecode(aux[0])); } else { xlsx.SetCellValue(i + 2, 6, HttpUtility.UrlDecode(step.Description)); } xlsx.SetCellStyle(i + 2, 6, style); if (step.ExpectedResult.Contains("$@#ITERATION@#")) { String[] aux = step.ExpectedResult.Split('$'); xlsx.SetCellValue(i + 2, 7, HttpUtility.UrlDecode(aux[0])); } else { xlsx.SetCellValue(i + 2, 7, HttpUtility.UrlDecode(step.ExpectedResult)); } xlsx.SetCellStyle(i + 2, 7, style); } else { xlsx.SetCellValue(i + 3, 5, HttpUtility.UrlDecode((Int32.Parse(step.Index) + 1).ToString())); xlsx.SetCellStyle(i + 3, 5, indexStyle); if (step.Description.Contains("$@#ITERATION@#")) { String[] aux = step.Description.Split('$'); xlsx.SetCellValue(i + 3, 6, HttpUtility.UrlDecode(aux[0])); } else { xlsx.SetCellValue(i + 3, 6, HttpUtility.UrlDecode(step.Description)); } xlsx.SetCellStyle(i + 3, 6, style); if (step.ExpectedResult.Contains("$@#ITERATION@#")) { String[] aux = step.ExpectedResult.Split('$'); xlsx.SetCellValue(i + 3, 7, HttpUtility.UrlDecode(aux[0])); } else { xlsx.SetCellValue(i + 3, 7, HttpUtility.UrlDecode(step.ExpectedResult)); } xlsx.SetCellStyle(i + 3, 7, style); } if (!testCase.Title.Equals("GeneralTestCase") && step.Index.Equals(1)) { xlsx.SetCellValue(i + 2, 3, HttpUtility.UrlDecode(step.Title)); } } xlsx.AutoFitRow(1, 10000); xlsx.AutoFitColumn(1, 18); #endregion } } xlsx.DeleteWorksheet(SLDocument.DefaultFirstSheetName); xlsx.SaveAs(path + @"\Plan.xlsx"); #endregion }
/// <summary> /// Extracts the generic parameteres from non shared step. /// </summary> /// <param name="currentTestStep">The current test step.</param> /// <param name="genericParameters">The generic parameters.</param> private static void ExtractGenericParameteresFromNonSharedStep(TestStep currentTestStep, Dictionary<string, Dictionary<string, string>> genericParameters) { Regex regexNamespaceInitializations = new Regex(RegexPatternNamespaceInitializations, RegexOptions.None); Regex regexNoNamespaceInitializations = new Regex(RegextPatternNoNamespaceInitializations, RegexOptions.None); string[] lines = null; if (currentTestStep.ActionTitle != null) { lines = currentTestStep.ActionTitle.Split(new string[] { "\n" }, StringSplitOptions.None); } if (lines != null) { foreach (string currentLine in lines) { Match m = regexNamespaceInitializations.Match(currentLine); if (m.Success) { if (!genericParameters.Keys.Contains(m.Groups["Namespace"].Value)) { Dictionary<string, string> genericTypesDictionary = new Dictionary<string, string>(); genericTypesDictionary.Add(m.Groups["GenParam"].Value, m.Groups["NewValue"].Value.Trim().TrimEnd(';')); genericParameters.Add(m.Groups["Namespace"].Value, genericTypesDictionary); } else { if (!genericParameters[m.Groups["Namespace"].Value].Keys.Contains(m.Groups["GenParam"].Value)) { genericParameters[m.Groups["Namespace"].Value].Add(m.Groups["GenParam"].Value, m.Groups["NewValue"].Value.Trim()); } else { genericParameters[m.Groups["Namespace"].Value][m.Groups["GenParam"].Value] = m.Groups["NewValue"].Value.Trim(); } } } else if (regexNoNamespaceInitializations.Match(currentLine).Success) { Match matchNoNamespace = regexNoNamespaceInitializations.Match(currentLine); if (!genericParameters.Keys.Contains(default(Guid).ToString())) { Dictionary<string, string> genericTypesDictionary = new Dictionary<string, string>(); genericTypesDictionary.Add(matchNoNamespace.Groups["GenParam"].Value, matchNoNamespace.Groups["NewValue"].Value.Trim()); genericParameters.Add(DefaultGuidString, genericTypesDictionary); } else { if (!genericParameters[DefaultGuidString].Keys.Contains(matchNoNamespace.Groups["GenParam"].Value)) { genericParameters[DefaultGuidString].Add(matchNoNamespace.Groups["GenParam"].Value, matchNoNamespace.Groups["NewValue"].Value.Trim()); } else { genericParameters[DefaultGuidString][matchNoNamespace.Groups["GenParam"].Value] = matchNoNamespace.Groups["NewValue"].Value.Trim(); } } } } } }
public void BTA_97_LN_CreateProductImage() { #region Object Initialization bool stepstatus = true; CategoryFields product = new CategoryFields(); ProjectBasePage basePages = new ProjectBasePage(driverContext); NonAdminUserData WebsiteData = new NonAdminUserData(driverContext); var application_Nav_Util_Page = new Application_Nav_Util_Page(DriverContext); var navigator_Users_ProgramPage = new Navigator_Users_ProgramPage(DriverContext); var Program_RewardCatalogPage = new Navigator_Users_Program_RewardCatalogPage(DriverContext); var rewardCatlog_productImagePage = new Navigator_Users_Program_RewardCatalog_ProductImagesPage(DriverContext); product.CategoryName = WebsiteData.ProductCategoryName; product.Name = WebsiteData.ProductName; string imageName = WebsiteData.ProductImageName + RandomDataHelper.RandomString(5); string imageOrder = WebsiteData.ProductImageOrder; testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); string stepName = ""; #endregion try { #region Step1:Launch Navigator Portal stepName = "Launch Navigator URL"; testStep = TestStepHelper.StartTestStep(testStep); var navigator_LoginPage = new Navigator_LoginPage(DriverContext); navigator_LoginPage.LaunchNavigatorPortal(login.Url, out string LaunchMessage); testStep.SetOutput(LaunchMessage); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step2:Login As User Admin User stepName = "Login As User Admin User and Navigate to Home page by selecting Organization and Environment"; testStep = TestStepHelper.StartTestStep(testStep); login.UserName = NavigatorUsers.NonAdminUser; login.Password = NavigatorUsers.NavigatorPassword; navigator_LoginPage.Login(login, Users.AdminRole.USER.ToString(), out string stroutput); testStep.SetOutput(stroutput); var navigator_UsersHomePage = new Navigator_UsersHomePage(DriverContext); navigator_UsersHomePage.Navigator_Users_SelectOrganizationEnvironment(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step3:Select the program application and verify the program configuration panel displayed stepName = "Select the program application and verify the program configuration panel displayed"; testStep = TestStepHelper.StartTestStep(testStep); application_Nav_Util_Page.OpenApplication(NavigatorEnums.ApplicationName.program); testStep.SetOutput("Program configuration panel opened successfully"); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step4: Click on reward catalog and verify product images tab displayed stepName = "Click on reward catalog and verify product images tab displayed"; testStep = TestStepHelper.StartTestStep(testStep); navigator_Users_ProgramPage.NavigateToProgramTab(Navigator_Users_ProgramPage.ProgramTabs.RewardCatalog); testStep.SetOutput("Reward catalog panel opened successfully with all the tabs including product image"); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step5: Click on product images tab and verify product images panel displayed stepName = "Click on product images tab and verify product images panel displayed"; testStep = TestStepHelper.StartTestStep(testStep); Program_RewardCatalogPage.NavigateToProgramRewardCatalogTab(Navigator_Users_Program_RewardCatalogPage.RewardCatalogTabs.ProductImages); testStep.SetOutput("Product images panel Openedsuccessfully"); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step6: Verify the existence of category and create category if doesn't exist stepName = "Verify the existence of category and create category if doesn't exist"; testStep = TestStepHelper.StartTestStep(testStep); rewardCatlog_productImagePage.VerifyCategoryExistanceAndCreateIfNotExists(product, out string outMessage); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step7: Verify the existence of product and create product if doesn't exist stepName = "Verify the existence of product and create product if doesn't exist"; testStep = TestStepHelper.StartTestStep(testStep); rewardCatlog_productImagePage.VerifyProductExistanceAndCreateIfNotExists(product, out outMessage); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step8: Click on create new product image button and verify new product image panel opened successfully stepName = "Click on create new product image button and verify new product image panel opened successfully"; testStep = TestStepHelper.StartTestStep(testStep); stepstatus = rewardCatlog_productImagePage.ClickOnCreateNewProductImageAndVerifyNewProductImagePanel(out outMessage); testStep.SetOutput(outMessage); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step9: Create a new product image stepName = "Create a new product image"; testStep = TestStepHelper.StartTestStep(testStep); stepstatus = rewardCatlog_productImagePage.CreateProductImage(product, imageName, imageOrder, out outMessage); testStep.SetOutput(outMessage); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step10: Verify the product image displayed in the table stepName = "Verify the product image displayed in the Product Image Grid"; testStep = TestStepHelper.StartTestStep(testStep); stepstatus = rewardCatlog_productImagePage.VerifyProductImageExists(imageName); testStep.SetOutput("ProductImage :" + imageName + " in the Product Image Grid"); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step11: Logout stepName = "Logout from USER page"; testStep = TestStepHelper.StartTestStep(testStep); navigator_LoginPage.Logout(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); testCase.SetImageContent(DriverContext.TakeScreenshot().ToString()); Assert.Fail(); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
/// <summary> /// Replaces the generic parameters with specified values. /// </summary> /// <param name="currentTestStep">The current test step.</param> /// <param name="genericParameters">The generic parameters.</param> private static void ReplaceGenericParametersWithSpecifiedValues(TestStep currentTestStep, Dictionary<string, Dictionary<string, string>> genericParameters) { Regex r1 = new Regex(RegextPatternStepTitle, RegexOptions.Singleline); if (genericParameters.Keys.Count > 0) { Match currentMatch = r1.Match(currentTestStep.Title); string genParamsStr = currentMatch.Groups["GenParam"].Value; string[] genParams = genParamsStr.Split(','); int initializeCount = genParams.Length; bool reinitialized = false; foreach (string currentNamespace in genericParameters.Keys) { if (currentMatch.Success) { if (currentMatch.Groups["Namespace"].Value.EndsWith(currentNamespace)) { currentTestStep.ActionTitle = currentTestStep.OriginalActionTitle; currentTestStep.ActionExpectedResult = currentTestStep.OriginalActionExpectedResult; currentTestStep.Title = currentTestStep.OriginalTitle; reinitialized = true; foreach (string currentKey in genericParameters[currentNamespace].Keys) { initializeCount--; string strToBeReplaced = String.Concat("(", currentKey, ")"); currentTestStep.ActionTitle = currentTestStep.ActionTitle.Replace(strToBeReplaced, genericParameters[currentNamespace][currentKey]); currentTestStep.ActionExpectedResult = currentTestStep.ActionExpectedResult.Replace(strToBeReplaced, genericParameters[currentNamespace][currentKey]); } foreach (string currentGenParam in genParams) { if (!genericParameters[currentNamespace].Keys.Contains(currentGenParam) && genericParameters.Keys.Contains(DefaultGuidString) && genericParameters[DefaultGuidString].Keys.Contains(currentGenParam)) { if (!reinitialized) { currentTestStep.ActionTitle = currentTestStep.OriginalActionTitle; currentTestStep.ActionExpectedResult = currentTestStep.OriginalActionExpectedResult; currentTestStep.Title = currentTestStep.OriginalTitle; } initializeCount--; string strToBeReplaced = String.Concat("(", currentGenParam, ")"); currentTestStep.ActionTitle = currentTestStep.ActionTitle.Replace(strToBeReplaced, genericParameters[DefaultGuidString][currentGenParam]); currentTestStep.ActionExpectedResult = currentTestStep.ActionExpectedResult.Replace(strToBeReplaced, genericParameters[DefaultGuidString][currentGenParam]); } } } } } if (initializeCount != 0) { foreach (string currentGenParam in genParams) { if (genericParameters.Keys.Contains(DefaultGuidString) && genericParameters[DefaultGuidString].Keys.Contains(currentGenParam) && initializeCount != 0) { if (!reinitialized) { currentTestStep.ActionTitle = currentTestStep.OriginalActionTitle; currentTestStep.ActionExpectedResult = currentTestStep.OriginalActionExpectedResult; currentTestStep.Title = currentTestStep.OriginalTitle; reinitialized = true; } initializeCount--; string strToBeReplaced = String.Concat("(", currentGenParam, ")"); currentTestStep.ActionTitle = currentTestStep.ActionTitle.Replace(strToBeReplaced, genericParameters[DefaultGuidString][currentGenParam]); currentTestStep.ActionExpectedResult = currentTestStep.ActionExpectedResult.Replace(strToBeReplaced, genericParameters[DefaultGuidString][currentGenParam]); } } } } else { currentTestStep.ActionTitle = currentTestStep.OriginalActionTitle; currentTestStep.ActionExpectedResult = currentTestStep.OriginalActionExpectedResult; } }
public List <TestCase> GetExcelSheetData(ExcelWorksheet eWorksheet) { List <TestCase> tcList = new List <TestCase>(); int usedRows, usedCols; if (eWorksheet.Dimension == null) { this._logger.Warn(new Exception("No TestCase, this Sheet is new!")); return(new List <TestCase>()); } else { usedRows = eWorksheet.Dimension.End.Row; usedCols = eWorksheet.Dimension.End.Column; } if (usedRows == 0 || usedRows == 1) { this._logger.Warn(new Exception("No TestCase!")); return(tcList); } for (int i = 1; i < eWorksheet.Dimension.End.Row; i++) { if (eWorksheet.Cells[i, 1].Text != null || eWorksheet.Cells[i, 1].Text.ToString() != string.Empty || !eWorksheet.Cells[i, 1].Text.ToString().Equals("END")) { continue; } usedRows = i; break; } TestCase tc = new TestCase(); for (int i = 2; i < usedRows; i++) { var currentCell = eWorksheet.Cells[i, 1]; //设置单元格格式为文本格式,防止为自定义格式时读取单元格报错 for (int j = 2; j <= 9; j++) { eWorksheet.Cells[i, j].Style.Numberformat.Format = "@"; } if (currentCell.Value == null) { TestStep ts = new TestStep { StepNumber = tc.TestSteps.Count + 1, ExecutionType = ExecType.手动, Actions = eWorksheet.Cells[i, 7].Text.ToString(), ExpectedResults = eWorksheet.Cells[i, 8].Text.ToString() }; tc.TestSteps.Add(ts); continue; } else { if (tc.ExternalId != null) { tcList.Add(tc); } tc = new TestCase { ExternalId = string.Format($"{currentCell.Text.ToString()}_{new Random().Next(0, 10000)}"), Name = eWorksheet.Cells[i, 2].Text.ToString(), Keywords = eWorksheet.Cells[i, 3].Text.ToString().Split(',').ToList(), Importance = CommonHelper.StrToImportanceType(eWorksheet.Cells[i, 4].Text.ToString()), ExecutionType = CommonHelper.StrToExecType(eWorksheet.Cells[i, 5].Text.ToString()), Summary = eWorksheet.Cells[i, 6].Text.ToString(), Preconditions = eWorksheet.Cells[i, 7].Text.ToString() }; TestStep tsOne = new TestStep { StepNumber = 1, ExecutionType = ExecType.手动, Actions = eWorksheet.Cells[i, 8].Text.ToString(), ExpectedResults = eWorksheet.Cells[i, 9].Text.ToString() }; tc.TestSteps = new List <TestStep> { tsOne }; } } return(tcList); }
/// <summary> /// Edits the test step action title. /// </summary> /// <param name="currentTestStep">The current test step.</param> /// <param name="newActionTitle">The new action title.</param> public static void EditTestStepActionTitle(TestStep currentTestStep, string newActionTitle) { UndoRedoManager.Instance().Push((step, t) => EditTestStepActionTitle(currentTestStep, t), currentTestStep, currentTestStep.OriginalActionTitle, "Change the test step action title"); log.InfoFormat("Change ActionTitle from {0} to {1}", currentTestStep.ActionTitle, newActionTitle); currentTestStep.ActionTitle = newActionTitle; currentTestStep.OriginalActionTitle = newActionTitle; }
private static TestResult RunTestFixture(ITestCommand testCommand, ConcordionTest concordionTest, TestStep parentTestStep) { ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep); // The magic happens here! var concordion = new ConcordionBuilder() .WithSource(concordionTest.Source) .WithTarget(concordionTest.Target) .WithSpecificationListener(new GallioResultRenderer()) .Build(); ConstructorInfo constructor = concordionTest.FixtureType.GetConstructor(Type.EmptyTypes); var fixture = constructor.Invoke(new object[] {}); var summary = concordion.Process(concordionTest.Resource, fixture); bool passed = !(summary.HasFailures || summary.HasExceptions); testContext.AddAssertCount((int)summary.SuccessCount + (int)summary.FailureCount); return(testContext.FinishStep(passed ? TestOutcome.Passed : TestOutcome.Failed, null)); }
public void BTA145_REST_GetMemberActivityDetail_Positive() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; common = new Common(this.DriverContext); rest_Service_Method = new REST_Service_Methods(common); try { Logger.Info("Test Method Started"); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member through rest service"; JObject member = (JObject)rest_Service_Method.PostMembergeneral(); var k = member.Value <String>("isError"); Logger.Info(k.GetType()); Logger.Info(member.Value <String>("isError")); if (member.Value <String>("isError") == "False") { testStep.SetOutput("Member is added through PostMember service and following are the details, IPCODE:= " + member["data"].Value <int>("id") + "; Name= " + member["data"].Value <String>("firstName"));; testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); } else { testStep.SetOutput(member.Value <String>("developerMessage")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); Logger.Info("test failed"); throw new Exception(member.Value <String>("developerMessage")); } testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding transaction through rest service by providing the VCKey for All Fields"; JObject response = (JObject)rest_Service_Method.PostTransactionWithVCKeyWithAllFields(member["data"]["cards"][0].Value <String>("id")); if (response.Value <String>("isError") == "False") { testStep.SetOutput("transactios Rowkey:" + response["data"]["transactions"].Value <String>("id")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); } else { testStep.SetOutput(response.Value <String>("developerMessage")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); Logger.Info("test failed"); throw new Exception(response.Value <String>("developerMessage")); } testStep = TestStepHelper.StartTestStep(testStep); stepName = "Fetching Account Details through rest service using Transaction Id"; String id = response["data"]["transactions"].Value <String>("transactionId"); JObject output = (JObject)rest_Service_Method.GetAccountDetailsByFMS(id); //JObject output = (JObject)rest_Service_Method.GetAccountDetailsByFMS("431321139150330186"); //testStep.SetOutput("saleAmount = " + output["data"][0]["additionalAttributes"][0].Value<string>("attributeValue")); testStep.SetOutput("Quantity = " + output["data"][0].Value <double>("quantity")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validating data with data from database"; String dbresponse = DatabaseUtility.GetQuantityfromDBUsingVCKeyREST(member["data"]["cards"][0].Value <String>("id")); testStep.SetOutput("Response from database" + dbresponse); Assert.AreEqual(output["data"][0].Value <double>("quantity") + "", dbresponse, "Expected value is " + output["data"][0].Value <double>("saleAmount") + " and actual value is " + dbresponse); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(true); Logger.Info("test passed"); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); Logger.Info("test failed" + e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA556_REST_PatchRedeemMemberReward_NEGATIVE() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); REST_Service_Methods rest_Service_Method = new REST_Service_Methods(common); try { Logger.Info("Test Method Started"); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member through rest service"; JObject member = (JObject)rest_Service_Method.PostMembergeneral(); var k = member.Value <string>("isError"); Logger.Info(k.GetType()); Logger.Info(member.Value <string>("isError")); if (member.Value <string>("isError") == "False") { testStep.SetOutput("IPCODE= " + member["data"].Value <int>("id") + "; Name= " + member["data"].Value <string>("firstName")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Fetching member rewards through rest service using IpCode"; JObject response = (JObject)rest_Service_Method.GetMemberRewardsByIpCode(member["data"].Value <int>("id") + ""); testStep.SetOutput("The member with IPCODE = " + response["data"][0].Value <int>("memberId") + " has the reward with rewardID = " + response["data"][0].Value <int>("rewardId")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Redeeming member rewards through rest service using RewardID"; response = (JObject)rest_Service_Method.PatchRedeemMemberRewardByUsingRewardId(response["data"][0].Value <int>("id") + ""); testStep.SetOutput("The member with IPCODE = " + response["data"].Value <int>("memberId") + " has redeemed the reward with rewardID = " + response["data"].Value <int>("id")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); Logger.Info("Test Method Started"); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Redeeming an already redeemed memberreward using rewardID through rest service"; response = (JObject)rest_Service_Method.PatchRedeemMemberRewardByUsingRewardId(response["data"].Value <int>("id") + ""); if (response.Value <string>("isError") == "True") { testStep.SetOutput("The response code from PatchRedeemMemberReward service for an already redeemed memberreward " + "with RewardId is " + response.Value <int>("responseCode") + ""); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate the user message for the above response code from the Service"; if (response.Value <int>("responseCode") == 50102) { testStep.SetOutput("userMessage from response is: " + response.Value <string>("userMessage")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); Logger.Info("test passed"); testCase.SetStatus(true); } else { Logger.Info("test failed"); testStep.SetOutput("response message is" + response.Value <string>("userMessage") + "and response code is" + response.Value <int>("responseCode")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); throw new Exception("response message is" + response.Value <string>("userMessage") + "and response code is" + response.Value <int>("responseCode")); } } else { Logger.Info("test failed"); testStep.SetOutput(response.Value <string>("userMessage")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); throw new Exception(response.Value <string>("userMessage")); } } } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
/// <summary> /// Adds the new shared step internal. /// </summary> /// <param name="testCase">The test case.</param> /// <param name="addedSharedStepGuids">The added shared step guids.</param> /// <param name="currentStep">The current step.</param> private void AddNewSharedStepInternal(TestCase testCase, List<Guid> addedSharedStepGuids, TestStep currentStep, int sharedStepId) { ISharedStep sharedStep = ExecutionContext.TestManagementTeamProject.SharedSteps.Find(sharedStepId); ISharedStepReference sharedStepReferenceCore = testCase.ITestCase.CreateSharedStepReference(); sharedStepReferenceCore.SharedStepId = sharedStep.Id; testCase.ITestCase.Actions.Add(sharedStepReferenceCore); addedSharedStepGuids.Add(currentStep.TestStepGuid); }
public void BTA556_REST_PatchRedeemMemberReward_POSITIVE() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); REST_Service_Methods rest_Service_Method = new REST_Service_Methods(common); try { Logger.Info("Test Method Started"); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member through rest service"; JObject member = (JObject)rest_Service_Method.PostMembergeneral(); var k = member.Value <string>("isError"); Logger.Info(k.GetType()); Logger.Info(member.Value <string>("isError")); if (member.Value <string>("isError") == "False") { testStep.SetOutput("IPCODE= " + member["data"].Value <int>("id") + "; Name= " + member["data"].Value <string>("firstName")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Fetching member rewards through rest service using IpCode"; JObject response = (JObject)rest_Service_Method.GetMemberRewardsByIpCode(member["data"].Value <int>("id") + ""); testStep.SetOutput("The member with IPCODE = " + response["data"][0].Value <int>("memberId") + " has the reward with rewardID = " + response["data"][0].Value <int>("rewardId")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Redeeming member rewards through rest service using RewardID"; response = (JObject)rest_Service_Method.PatchRedeemMemberRewardByUsingRewardId(response["data"][0].Value <int>("id") + ""); testStep.SetOutput("The member with IPCODE = " + response["data"].Value <int>("memberId") + " has redeemed the reward with rewardID = " + response["data"].Value <int>("id")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate the redemptiondate got from response with DB"; string dbresponse = DatabaseUtility.GetRedemptionDatefromDBUsingRewardIdREST(response["data"].Value <int>("id") + ""); DateTime datedb = Convert.ToDateTime(dbresponse).Date; DateTime resp = Convert.ToDateTime(response["data"].Value <DateTime>("redemptionDate")).Date; Assert.AreEqual(resp, datedb, "Expected value is " + resp + " and actual value is " + datedb); testStep.SetOutput("Redemption Date returned from db is " + dbresponse + " which matches with the Redemption Date from the response: " + resp); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); Logger.Info("test passed"); testCase.SetStatus(true); } else { Logger.Info("test failed"); testStep.SetOutput(member.Value <string>("developerMessage")); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); throw new Exception(member.Value <string>("developerMessage")); } } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public VerifyCommand(TestStep testStep) : base(testStep) { }
public void GetStepByTypeForNull() { WxeStep step = TestStep.GetStepByType <WxeStep> (null); Assert.That(step, Is.Null); }