private void SetDetailTabDataForAg(DetailTabData detailTabData)
        {
            SetReactCheckBoxState(_chkIsAutoGeneratedName, detailTabData.AutoGenerateName);

            if (!detailTabData.AutoGenerateName)
            {
                ClearInputAndTypeValue(_txtPlacementName, detailTabData.Name);
            }

            var flightDates = new FlightDates
            {
                StartDate = detailTabData.StartDate,
                EndDate   = detailTabData.EndDate
            };

            flightDates = GetActualFlightDates(flightDates);

            EnterDate(_txtStartDate, flightDates.StartDate);
            EnterDate(_txtEndDate, flightDates.EndDate);

            if (ConvertToPurchaseTypeEnum(detailTabData.PurchaseType) == PurchaseType.CPD)
            {
                try
                {
                    Wait.Until(driver => _txtGoal.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.Goal));
                }
                catch
                {
                    Assert.Fail($"CPD Goal mismatch.\nExpected: {detailTabData.Goal}\nActual: {_txtGoal.GetAttribute("value").Replace(", ", string.Empty)}");
                }
            }

            if (!string.IsNullOrEmpty(detailTabData.TargetingType))
            {
                ScrollAndClickElement(_ddlTargetingType);
                SelectSingleValueFromReactDropdownByText(_ddlTargetingType, detailTabData.TargetingType);
                ScrollAndClickElement(_ddlTargetingOptions);
                Wait.Until(d => !IsElementPresent(By.XPath("//div[contains(@class,'select-component targeting-options select-component--is-disabled')]")));
                SelectMultipleValuesFromReactDropdownByText(_ddlTargetingOptions, detailTabData.TargetingOptions);
            }

            ValidateAutoCalculatedField(detailTabData);
        }
        private void SetDetailTabData(DetailTabData detailTabData)
        {
            ClickTab("Details");

            SetReactCheckBoxState(_chkIsAutoGeneratedPackageName, detailTabData.AutoGenerateName);

            if (!detailTabData.AutoGenerateName)
            {
                ClearInputAndTypeValue(_txtPackageName, detailTabData.Name);
            }

            SelectSingleValueFromReactDropdownByText(_ddlPublisher, detailTabData.Publisher);
            SelectSingleValueFromReactDropdownByText(_ddlSite, detailTabData.Site);

            if (!string.IsNullOrWhiteSpace(detailTabData.Supplier))
            {
                SelectSingleValueFromReactDropdownByText(_ddlSupplier, detailTabData.Supplier);
            }

            if (string.IsNullOrWhiteSpace(detailTabData.StartDate))
            {
                detailTabData.StartDate = GetTodaysDate();
            }
            else if (detailTabData.StartDate == "dayAfterCurrentDate")
            {
                detailTabData.StartDate = GetFutureDate(GetTodaysDate(), 1, "Days");
            }

            if (string.IsNullOrWhiteSpace(detailTabData.EndDate))
            {
                detailTabData.EndDate = GetFutureDate(detailTabData.StartDate, 3);
            }

            EnterDate(_txtStartDate, detailTabData.StartDate);
            EnterDate(_txtEndDate, detailTabData.EndDate);

            if (!string.IsNullOrWhiteSpace(detailTabData.ClientAgreement))
            {
                SelectSingleValueFromReactDropdownByText(_ddlClientAgreement, detailTabData.ClientAgreement);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.FrequencyCapImpressions))
            {
                ClearInputAndTypeValue(_txtFrequencyCapImpressions, detailTabData.FrequencyCapImpressions);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.FrequencyCapDuration))
            {
                ClearInputAndTypeValue(_txtFrequencyCapDuration, detailTabData.FrequencyCapDuration);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.FrequencyCapInterval))
            {
                SelectSingleValueFromReactDropdownByText(_ddlFrequencyCapInterval, detailTabData.FrequencyCapInterval);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.Currency))
            {
                SelectSingleValueFromReactDropdownByText(_ddlCurrency, detailTabData.Currency);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.ExchangeRate))
            {
                Wait.Until(driver => _txtExchangeRate.GetAttribute("disabled") == null);
                ClearInputAndTypeValue(_txtExchangeRate, detailTabData.ExchangeRate);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.PurchaseType))
            {
                SelectSingleValueFromReactDropdownByText(_ddlPurchaseType, detailTabData.PurchaseType);
            }

            ValidateAutoCalculatedField(detailTabData);
            ValidateReverseCalculateFromNetFields(detailTabData);
        }
 private void SetDetailTabDataForAg(DetailTabData detailTabData)
 {
     ValidateAutoCalculatedField(detailTabData);
 }
        private void SetDetailTabData(DetailTabData detailTabData, bool isSponsorshipChildItem)
        {
            ClickTab("Details");
            SetReactCheckBoxState(_chkIsAutoGeneratedName, detailTabData.AutoGenerateName);

            if (!detailTabData.AutoGenerateName)
            {
                ClearInputAndTypeValue(_txtPlacementName, detailTabData.Name);
            }

            if (!isSponsorshipChildItem)
            {
                ClearSelectedValueFromReactDropdown(_ddlPublisher);
                SelectSingleValueFromReactDropdownByText(_ddlPublisher, detailTabData.Publisher);
            }

            ClearSelectedValueFromReactDropdown(_ddlSite);
            SelectSingleValueFromReactDropdownByText(_ddlSite, detailTabData.Site);

            if (!string.IsNullOrWhiteSpace(detailTabData.Supplier))
            {
                SelectSingleValueFromReactDropdownByText(_ddlSupplier, detailTabData.Supplier);
            }

            SelectSingleValueFromReactDropdownByText(_ddlLocation, detailTabData.Location);
            SelectSingleValueFromReactDropdownByText(_ddlFormat, detailTabData.Format);

            //// TODO - Handle Width and Height as we need to additionally check whether element is disabled

            if (!string.IsNullOrWhiteSpace(detailTabData.CreativeType))
            {
                SelectSingleValueFromReactDropdownByText(_ddlCreativeType, detailTabData.CreativeType);
            }

            if (detailTabData.Devices != null && detailTabData.Devices.Any())
            {
                RemoveAllItemsFromMultiSelect(_ddlDevices);
                SelectMultipleValuesFromReactDropdownByText(_ddlDevices, detailTabData.Devices);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.LandingPage))
            {
                ClearInputAndTypeValue(_txtLandingPage, detailTabData.LandingPage);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.TargetingComments))
            {
                ClearInputAndTypeValue(_txtTargetingComments, detailTabData.TargetingComments);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.FrequencyCapImpressions))
            {
                ClearInputAndTypeValue(_txtFrequencyCapImpressions, detailTabData.FrequencyCapImpressions);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.FrequencyCapDuration))
            {
                ClearInputAndTypeValue(_txtFrequencyCapDuration, detailTabData.FrequencyCapDuration);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.FrequencyCapInterval))
            {
                SelectSingleValueFromReactDropdownByText(_ddlFrequencyCapInterval, detailTabData.FrequencyCapInterval);
            }

            if (string.IsNullOrWhiteSpace(detailTabData.StartDate))
            {
                detailTabData.StartDate = GetTodaysDate();
            }
            else if (detailTabData.StartDate == "dayAfterCurrentDate")
            {
                detailTabData.StartDate = GetFutureDate(GetTodaysDate(), 1, "Days");
            }

            if (string.IsNullOrWhiteSpace(detailTabData.EndDate))
            {
                detailTabData.EndDate = GetFutureDate(detailTabData.StartDate, 3);
            }

            EnterDate(_txtStartDate, detailTabData.StartDate);
            EnterDate(_txtEndDate, detailTabData.EndDate);

            var placementStartDate = DateTime.ParseExact(detailTabData.StartDate, "dd MMM yyyy", CultureInfo.InvariantCulture).ToString("yyyyMM");

            FeatureContext.Add(detailTabData.Name, placementStartDate);

            if (!string.IsNullOrWhiteSpace(detailTabData.ClientAgreement))
            {
                SelectSingleValueFromReactDropdownByText(_ddlClientAgreement, detailTabData.ClientAgreement);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.Currency))
            {
                SelectSingleValueFromReactDropdownByText(_ddlCurrency, detailTabData.Currency);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.ExchangeRate))
            {
                Wait.Until(driver => _txtExchangeRate.GetAttribute("disabled") == null);
                ClearInputAndTypeValue(_txtExchangeRate, detailTabData.ExchangeRate);
            }

            if (!string.IsNullOrWhiteSpace(detailTabData.PurchaseType))
            {
                SelectSingleValueFromReactDropdownByText(_ddlPurchaseType, detailTabData.PurchaseType);
            }

            if (detailTabData.IsDefaultRate)
            {
                Assert.AreEqual(_txtBaseRate.GetAttribute("value"), detailTabData.BaseRate);
                Assert.AreEqual(_txtRatecardRate.GetAttribute("value"), detailTabData.RatecardRate);
            }

            ValidateAutoCalculatedField(detailTabData);
            ValidateReverseCalculateFromNetFields(detailTabData);

            if (!string.IsNullOrWhiteSpace(detailTabData.ShareOfVoice))
            {
                ClearInputAndTypeValue(_txtSov, detailTabData.ShareOfVoice);
            }

            if (detailTabData.CustomFields != null && detailTabData.CustomFields.Any())
            {
                foreach (var customFieldData in detailTabData.CustomFields)
                {
                    var customFieldElement = FindElementByXPath($"//label[text() = '{customFieldData.Name}']");
                    SetCustomFieldElement(customFieldElement, customFieldData.Type, customFieldData.Values);
                }
            }
        }
Beispiel #5
0
        protected void ValidateReverseCalculateFromNetFields(DetailTabData detailTabData)
        {
            if (detailTabData.NetCost == null || detailTabData.NetRate == null)
            {
                return;
            }

            if (!IsElementPresent(By.Id("msaddedit_costs_netCost")) || !IsElementPresent(By.Id("msaddedit_costs_netRate")))
            {
                return;
            }

            var errorMsg = new StringBuilder();

            switch (detailTabData.AutoCalculateField.ToLower())
            {
            case "rate":
                ClearInputAndTypeValue(_txtNetCost, detailTabData.NetCost);
                try
                {
                    Wait.Until(driver => _txtNetRate.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.NetRate));
                    Wait.Until(driver => _txtBaseCost.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.BaseCost));
                }
                catch (WebDriverTimeoutException)
                {
                    errorMsg.Append($"Actual Net Rate or Base Cost does NOT contain expected values:");
                    errorMsg.Append($"\nActual Net Rate: {_txtRatecardCost.GetAttribute("value").Replace(",", string.Empty)}\nExpected: {detailTabData.NetRate}");
                    errorMsg.Append($"\nActual Base Cost: {_txtBaseCost.GetAttribute("value").Replace(",", string.Empty)}\nExpected: {detailTabData.BaseCost}");
                }
                break;

            case "cost":
                ClearInputAndTypeValue(_txtNetRate, detailTabData.NetRate);
                try
                {
                    Wait.Until(driver => _txtNetRate.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.NetCost));
                    Wait.Until(driver => _txtBaseCost.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.BaseCost));
                }
                catch (WebDriverTimeoutException)
                {
                    errorMsg.Append($"Actual Net Cost or Base Cost does NOT contain expected values:");
                    errorMsg.Append($"\nActual Net Rate: {_txtRatecardCost.GetAttribute("value").Replace(",", string.Empty)}\nExpected: {detailTabData.NetCost}");
                    errorMsg.Append($"\nActual Base Cost: {_txtBaseCost.GetAttribute("value").Replace(",", string.Empty)}\nExpected: {detailTabData.BaseCost}");
                }
                break;

            case "goal":
                ClearInputAndTypeValue(_txtNetRate, detailTabData.NetRate);
                ClearInputAndTypeValue(_txtNetCost, detailTabData.NetCost);
                try
                {
                    Wait.Until(driver => _txtBaseCost.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.BaseCost));
                }
                catch (WebDriverTimeoutException)
                {
                    errorMsg.Append($"Actual Base Cost does NOT contain expected values:");
                    errorMsg.Append($"\nActual Base Cost: {_txtBaseCost.GetAttribute("value").Replace(",", string.Empty)}\nExpected: {detailTabData.BaseCost}");
                }
                break;
            }
        }
Beispiel #6
0
        protected void ValidateAutoCalculatedField(DetailTabData detailTabData)
        {
            var isAutoCalculatedFieldMatch = true;
            var errorMsg     = new StringBuilder();
            var purchaseType = ConvertToPurchaseTypeEnum(detailTabData.PurchaseType);

            if (detailTabData.PurchaseType != null && detailTabData.PurchaseType.Equals(FIXED_PURCHASE_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                if (!string.IsNullOrWhiteSpace(detailTabData.Goal) && purchaseType.IsGoalEditableForPurchaseType())
                {
                    ClearInputAndTypeValue(_txtGoal, detailTabData.Goal);
                }

                ClearInputAndTypeValue(_txtBaseCost, detailTabData.BaseCost);
                ClearInputAndTypeValueIfRequired(_txtRatecardCost, detailTabData.RatecardCost);

                return;
            }

            switch (detailTabData.AutoCalculateField.ToLower())
            {
            case "goal":
                ScrollAndClickElement(_rdoGoal);
                ClearInputAndTypeValue(_txtBaseRate, detailTabData.BaseRate);
                ClearInputAndTypeValue(_txtBaseCost, detailTabData.BaseCost);
                ClearInputAndTypeValueIfRequired(_txtRatecardRate, detailTabData.RatecardRate);
                ClearInputAndTypeValueIfRequired(_txtRatecardCost, detailTabData.RatecardCost);
                try
                {
                    Wait.Until(driver => _txtGoal.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.Goal));
                }
                catch (WebDriverTimeoutException)
                {
                    isAutoCalculatedFieldMatch = false;
                    errorMsg.Append($"Actual Goal: {_txtGoal.GetAttribute("value").Replace(",", string.Empty)} does NOT contain: {detailTabData.Goal}");
                }
                break;

            case "rate":
                ScrollAndClickElement(_rdoRate);
                if (!string.IsNullOrWhiteSpace(detailTabData.Goal) && purchaseType.IsGoalEditableForPurchaseType())
                {
                    ClearInputAndTypeValue(_txtGoal, detailTabData.Goal);
                }
                ClearInputAndTypeValue(_txtBaseCost, detailTabData.BaseCost);
                ClearInputAndTypeValueIfRequired(_txtRatecardCost, detailTabData.RatecardCost);
                try
                {
                    Wait.Until(driver => _txtBaseRate.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.BaseRate));
                    Wait.Until(driver => _txtRatecardRate.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.RatecardRate));
                }
                catch (WebDriverTimeoutException)
                {
                    isAutoCalculatedFieldMatch = false;
                    errorMsg.Append($"Actual Base Rate or Ratecard Rate does NOT contain expected values:");
                    errorMsg.Append($"\nActual Base Rate: {_txtBaseRate.GetAttribute("value").Replace(",", string.Empty)}\nExpected: {detailTabData.BaseRate}");
                    errorMsg.Append($"\nActual Ratecard Rate: {_txtRatecardRate.GetAttribute("value").Replace(",", string.Empty)}\nExpected: {detailTabData.RatecardRate}");
                }
                break;

            case "cost":
                ScrollAndClickElement(_rdoCost);
                if (!string.IsNullOrWhiteSpace(detailTabData.Goal) && purchaseType.IsGoalEditableForPurchaseType())
                {
                    ClearInputAndTypeValue(_txtGoal, detailTabData.Goal);
                }
                ClearInputAndTypeValue(_txtBaseRate, detailTabData.BaseRate);
                ClearInputAndTypeValueIfRequired(_txtRatecardRate, detailTabData.RatecardRate);
                try
                {
                    Wait.Until(driver => _txtBaseCost.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.BaseCost));
                    Wait.Until(driver => _txtRatecardCost.GetAttribute("value").Replace(",", string.Empty).Contains(detailTabData.RatecardCost));
                }
                catch (WebDriverTimeoutException)
                {
                    isAutoCalculatedFieldMatch = false;
                    errorMsg.Append($"Actual Base Cost or Ratecard Cost does NOT contain expected values:");
                    errorMsg.Append($"\nActual Base Cost: {_txtBaseCost.GetAttribute("value").Replace(",", string.Empty)}\nExpected: {detailTabData.BaseCost}");
                    errorMsg.Append($"\nActual Ratecard Cost: {_txtRatecardCost.GetAttribute("value").Replace(",", string.Empty)}\nExpected: {detailTabData.RatecardCost}");
                }
                break;
            }

            if (!isAutoCalculatedFieldMatch)
            {
                Assert.Fail(errorMsg.ToString());
            }
        }