public void ThenISeeDistributionSummaryCardsAndAllValuesAreCorrect(Table table) { ScenarioContext.Current.Add("Parameters Table", table); TableRows expected = table.Rows; List <DistributionSummaryItemData> summaryCards = distributionTab.GetSummaryItems(); //check each item in given order, positions should match for (int i = 0; i < expected.Count; i++) { //expected values in this position TableRow row = expected[i]; string expDistributionName = row["Distribution Name"]; string expStatus = row["Status"]; string expModifiedPayment = row["Modified Payment"]; string expCalculatedPayment = row["Calculated Payment"]; string expDifference = row["Difference"]; string expUpdatedDate = row["Updated Date"]; //actual values in this position DistributionSummaryItemData item = summaryCards[i]; //verifications item.DistributionName.Should().Be(expDistributionName, expDistributionName + " Card: Distribution Name is correct"); item.Status.Should().Be(expStatus, expDistributionName + " Card: Status is correct"); if (item.Status == "EDITABLE") { item.CardUIStyle.Should().Be("BlueHeader", "Editable Distributions have Blue header"); } else { item.CardUIStyle.Should().Be("GreyHeader", "Posted Distributions have Grey header"); } item.ModifiedPaymentLabel.Should().Be("Modified Payment", expDistributionName + "Card: Modified Payment Label is correct"); item.ModifiedPayment.Should().Be(expModifiedPayment, expDistributionName + "Card: Modified Payment Value is correct"); item.CalculatedPaymentLabel.Should().Be("Calculated Payment", expDistributionName + "Card: Calculated Payment Label is correct"); item.CalculatedPayment.Should().Be(expCalculatedPayment, expDistributionName + "Card: Calculated Payment Value is correct"); item.DifferenceLabel.Should().Be("Difference", expDistributionName + "Card: Difference Label is correct"); item.Difference.Should().Be(expDifference, expDistributionName + "Card: Difference Value is correct"); item.UpdatedDateLabel.Should().Be("Updated Date", expDistributionName + "Card: Updated Date Label is correct"); item.UpdatedDate.Should().Be(expUpdatedDate, expDistributionName + "Card: Updated Date Value is correct"); } }
//DISTRIBUTION SUMMARY SECTION public List <DistributionSummaryItemData> GetSummaryItems() { //move to view the full cards this.MoveToViewElement(this.WaitForElementToBeVisible(SUMMARY_SECTION_TITLE_LOCATOR)); //gEt all cards on summary carousel IReadOnlyCollection <IWebElement> summaryItems = this.WaitForElementsToBeVisible(SUMMARY_ITEM_LOCATOR); List <DistributionSummaryItemData> retItems = new List <DistributionSummaryItemData>(); IWebElement previousCard = null; //Get content from all Summary Cards foreach (var weItem in summaryItems) { DistributionSummaryItemData item = new DistributionSummaryItemData(); //Set visible STYLE according to style applied to Summary Card if (weItem.GetAttribute("class").Contains("grey")) { item.CardUIStyle = "GreyHeader"; } else { item.CardUIStyle = "BlueHeader"; } //Get "Distribution Name" IWebElement distributionNameWE = weItem.FindElement(SUMMARY_ITEM_NAME_LOCATOR); item.DistributionName = distributionNameWE.Text; item.DistributionNameEllipsis = distributionNameWE.GetAttribute("class").Contains("ellipsis"); //Get "Distribution Status" item.Status = weItem.FindElement(SUMMARY_ITEM_STATUS_LOCATOR).Text; //Set different locators for modidifed payment and calculated payment according to status //TODO change when fixed them to be unique classes per each field By modifiedPaymentLabelLocator; By modifiedPaymentLocator; By calculatedPaymentLabelLocator; By calculatedPaymentLocator; if (item.CardUIStyle == "BlueHeader") { modifiedPaymentLabelLocator = By.XPath(String.Format(SUMMARY_ITEM_LABEL_LOCATOR_TEMPLATE, "claimBalanceRow")); modifiedPaymentLocator = By.XPath(String.Format(SUMMARY_ITEM_VALUE_LOCATOR_TEMPLATE, "claimBalanceRow")); calculatedPaymentLabelLocator = By.XPath(String.Format(SUMMARY_ITEM_LABEL_LOCATOR_TEMPLATE, "claimClaimedRow")); calculatedPaymentLocator = By.XPath(String.Format(SUMMARY_ITEM_VALUE_LOCATOR_TEMPLATE, "claimClaimedRow")); } else { modifiedPaymentLabelLocator = SUMMARY_ITEM_MOD_PAYMENT_GREY_LABEL_LOCATOR; modifiedPaymentLocator = SUMMARY_ITEM_MOD_PAYMENT_GREY_VALUE_LOCATOR; calculatedPaymentLabelLocator = SUMMARY_ITEM_CALC_PAYMENT_GREY_LABEL_LOCATOR; calculatedPaymentLocator = SUMMARY_ITEM_CALC_PAYMENT_GREY_VALUE_LOCATOR; } //Get "Modified Payment" label and value item.ModifiedPaymentLabel = weItem.FindElement(modifiedPaymentLabelLocator).Text; item.ModifiedPayment = weItem.FindElement(modifiedPaymentLocator).Text; //IF Modified Payment CAME BLANK, card is not visible, so SWIPE TO THE LEFT if (item.ModifiedPayment == "") { //Swipe int offset = -(previousCard.Size.Width) / 2; Actions action = new Actions(driver); action.MoveToElement(previousCard).DragAndDropToOffset(previousCard, offset, 0).Build().Perform(); //Get Modified Payment value again item.ModifiedPayment = weItem.FindElement(modifiedPaymentLocator).Text; } //Calculated Payment label and value item.CalculatedPaymentLabel = weItem.FindElement(calculatedPaymentLabelLocator).Text; item.CalculatedPayment = weItem.FindElement(calculatedPaymentLocator).Text; //Difference item.DifferenceLabel = weItem.FindElement(By.XPath(String.Format(SUMMARY_ITEM_LABEL_LOCATOR_TEMPLATE, "claimPaidRow"))).Text; item.Difference = weItem.FindElement(By.XPath(String.Format(SUMMARY_ITEM_VALUE_LOCATOR_TEMPLATE, "claimPaidRow"))).Text; //Updated Date item.UpdatedDateLabel = weItem.FindElement(By.XPath(String.Format(SUMMARY_ITEM_LABEL_LOCATOR_TEMPLATE, "claimReservedRow"))).Text; item.UpdatedDate = weItem.FindElement(By.XPath(String.Format(SUMMARY_ITEM_VALUE_LOCATOR_TEMPLATE, "claimReservedRow"))).Text; // Add this item to the returned list retItems.Add(item); //save this as previous card in case of need for swipping on next card previousCard = weItem; } return(retItems); }