public Dictionary <NonMediaCostData, bool> VerifyAllNonMediaCostsDisplayed(List <NonMediaCostData> nonMediaCosts)
        {
            var rowGroups = GetRowGroupings("non-media-cost-item");
            var isNonMediaCostsDisplayed = new Dictionary <NonMediaCostData, bool>();

            if (nonMediaCosts == null || !nonMediaCosts.Any() || !rowGroups.Any())
            {
                throw new ArgumentNullException($"Non media costs were missed in test data.");
            }

            foreach (var nonMediaCost in nonMediaCosts)
            {
                var rowGroup = new RowGrouping();
                ScrollRightUntilElementIsDisplayed(_scrollBar, _scrollableArea, "//div[contains(@data-test-selector,'rate-card-cost')]");
                try
                {
                    rowGroup = rowGroups.First(rg => ElementContainsText(rg.FixedColumns, nonMediaCost.Name));
                }
                catch (InvalidOperationException)
                {
                    throw new Exception($"The expected non media cost '{nonMediaCost.Name}' doesnot exist on the Media Schedule grid page");
                }
                var isVendorFound        = ElementContainsText(rowGroup.FixedColumns, nonMediaCost.Vendor);
                var agencyCostData       = decimal.Parse(nonMediaCost.AgencyCost).ToString("N2");
                var isAgencyCostFound    = ElementContainsText(rowGroup.ScrollableColumns, agencyCostData);
                var isNonMediaCostsFound = (isVendorFound && isAgencyCostFound);
                isNonMediaCostsDisplayed.Add(nonMediaCost, isNonMediaCostsFound);
            }

            return(isNonMediaCostsDisplayed);
        }
        public Dictionary <CustomBillingItem, bool> VerifyAllBilledGoalsDisplayed(List <CustomBillingItem> customBillingItems)
        {
            ExpandAllPackages();

            var rows = GetAllRows();
            var areBilledGoalsDisplayed = new Dictionary <CustomBillingItem, bool>();

            if (customBillingItems == null || !customBillingItems.Any() || !rows.Any())
            {
                throw new ArgumentNullException($"Custom billing items not found in test data.");
            }

            foreach (var item in customBillingItems)
            {
                var rowGroup = new RowGrouping();
                ScrollRightUntilElementIsDisplayed(_scrollBar, _scrollableArea, "//div[contains(@data-test-selector,'version')]");
                try
                {
                    var itemName = ReplaceItemNamePlaceholderText(item.Name);
                    rowGroup = rows.First(rg => ElementContainsText(rg.FixedColumns, itemName));
                }
                catch (InvalidOperationException)
                {
                    throw new Exception($"The expected billed goal for '{item.Name}' does not exist on the Medis Schedule Grid page");
                }
                var isBilledGoalFound = ElementContainsText(rowGroup.ScrollableColumns, item.BilledGoal);
                areBilledGoalsDisplayed.Add(item, isBilledGoalFound);
            }

            return(areBilledGoalsDisplayed);
        }
        public bool VerifyAllSponsorshipPackagesExist(List <SponsorshipPackage> sponsorshipPackages)
        {
            var rowGroups = GetRowGroupings("sponsorship");

            if (sponsorshipPackages == null || !sponsorshipPackages.Any() || !rowGroups.Any())
            {
                return(false);
            }

            foreach (var sponsorshipPackage in sponsorshipPackages)
            {
                var rowGroup = new RowGrouping();
                try
                {
                    rowGroup = rowGroups.First(rg => ElementContainsText(rg.FixedColumns, sponsorshipPackage.SponsorshipPackageName));
                }
                catch (InvalidOperationException)
                {
                    throw new Exception($"The expected sponsorship package '{sponsorshipPackage.SponsorshipPackageName}' doesnot exist on the Media Schedule grid page");
                }
                var rowFixedColumns      = rowGroup.FixedColumns;
                var rowScrollableColumns = rowGroup.ScrollableColumns;

                var publisherData    = sponsorshipPackage.Publisher.Contains("(") ? sponsorshipPackage.Publisher.Substring(0, sponsorshipPackage.Publisher.IndexOf('(')).Trim() : sponsorshipPackage.Publisher;
                var isPublisherFound = ElementContainsText(rowFixedColumns, publisherData);

                if (!isPublisherFound)
                {
                    return(false);
                }
            }

            return(true);
        }
        public bool VerifyAllPerformancePackageExist(List <PerformancePackage> performancePackages)
        {
            var rowGroups = GetRowGroupings("performance");

            if (performancePackages == null || !performancePackages.Any() || !rowGroups.Any())
            {
                throw new NotFoundException("Performance packages missing in test data");
            }

            foreach (var performancePackage in performancePackages)
            {
                var rowGroup = new RowGrouping();

                ScrollRightUntilElementIsDisplayed(_scrollBar, _scrollableArea, "//div[contains(@data-test-selector, 'goal')]");
                var rowName = performancePackage.IsAutomatedGuaranteedItem ? performancePackage.DetailTabData.Name
                    : performancePackage.DetailTabData.AutoGenerateName ? performancePackage.ExpectedPackageName
                    : performancePackage.DetailTabData.Name;
                try
                {
                    rowGroup = rowGroups.First(rg => ElementContainsText(rg.FixedColumns, rowName));
                }
                catch (InvalidOperationException)
                {
                    throw new Exception($"The expected performance package '{rowName}' doesnot exist on the Media Schedule grid page");
                }
                var rowFixedColumns      = rowGroup.FixedColumns;
                var rowScrollableColumns = rowGroup.ScrollableColumns;

                var siteData    = performancePackage.DetailTabData.Site;
                var isSiteFound = ElementContainsText(rowFixedColumns, siteData);

                var publisherData    = performancePackage.DetailTabData.Publisher.Contains("(") ? performancePackage.DetailTabData.Publisher.Substring(0, performancePackage.DetailTabData.Publisher.IndexOf('(')).Trim() : performancePackage.DetailTabData.Publisher;
                var isPublisherFound = ElementContainsText(rowFixedColumns, publisherData);

                var purchaseTypeData    = performancePackage.DetailTabData.PurchaseType;
                var isPurchaseTypeFound = ElementContainsText(rowScrollableColumns, purchaseTypeData);

                var goalData    = int.Parse(performancePackage.DetailTabData.Goal).ToString("N0");
                var isGoalFound = ElementContainsText(rowScrollableColumns, goalData);

                if (!isSiteFound || !isPublisherFound || !isPurchaseTypeFound || !isGoalFound)
                {
                    Console.WriteLine($"ERROR: Line item containing text '{siteData}', '{publisherData}', '{purchaseTypeData}', or '{goalData}' not found.");
                    Console.WriteLine($"Site found: {isSiteFound}\nPublisher found:{isPublisherFound}\nIsPurchaseTypeFound: {isPurchaseTypeFound}\nIsGoalFound: {isGoalFound}");
                    return(false);
                }
            }

            return(true);
        }
        public bool VerifyAllSinglePlacementsExist(List <SinglePlacement> singlePlacements)
        {
            var rowGroups = GetRowGroupings("placement");

            if (singlePlacements == null || !singlePlacements.Any() || !rowGroups.Any())
            {
                throw new NotFoundException("Single placements missing in test data");
            }

            foreach (var singlePlacement in singlePlacements)
            {
                var rowName = singlePlacement.IsImportedItem || !singlePlacement.DetailTabData.AutoGenerateName ? singlePlacement.DetailTabData.Name
                    : ReplaceItemNamePlaceholderText(singlePlacement.DetailTabData.Name);

                var rowGroup = new RowGrouping();
                try
                {
                    rowGroup = rowGroups.First(rg => ElementContainsText(rg.FixedColumns, rowName));
                }
                catch (InvalidOperationException)
                {
                    throw new Exception($"The expected single placement '{rowName}' does not exist on the Media Schedule grid page");
                }
                var rowFixedColumns      = rowGroup.FixedColumns;
                var rowScrollableColumns = rowGroup.ScrollableColumns;

                var siteData    = singlePlacement.DetailTabData.Site;
                var isSiteFound = ElementContainsText(rowFixedColumns, siteData);

                var publisherData    = singlePlacement.DetailTabData.Publisher.Contains("(") ? singlePlacement.DetailTabData.Publisher.Substring(0, singlePlacement.DetailTabData.Publisher.IndexOf('(')).Trim() : singlePlacement.DetailTabData.Publisher;
                var isPublisherFound = ElementContainsText(rowFixedColumns, publisherData);

                var locationData    = singlePlacement.DetailTabData.Location;
                var isLocationFound = ElementContainsText(rowScrollableColumns, locationData);

                var creativeTypeData    = singlePlacement.DetailTabData.CreativeType;
                var isCreativeTypeFound = ElementContainsText(rowScrollableColumns, creativeTypeData);

                if (!isSiteFound || !isPublisherFound || !isCreativeTypeFound)
                {
                    Console.WriteLine($"ERROR: Line item containing text '{siteData}', '{publisherData}', or '{creativeTypeData}' not found.");
                    Console.WriteLine($"Site found: {isSiteFound}\nPublisher found:{isPublisherFound}\nIsCreativeTypeFound: {isCreativeTypeFound}");
                    return(false);
                }
            }

            return(true);
        }
        public bool VerifyAllPerformancePackageExistAsAg(List <PerformancePackage> performancePackages)
        {
            var rowGroups = GetRowGroupings("performance");

            if (performancePackages == null || !performancePackages.Any() || !rowGroups.Any())
            {
                throw new NotFoundException("Performance packages missing in test data");
            }

            foreach (var performancePackage in performancePackages)
            {
                var rowGroup = new RowGrouping();

                ScrollRightUntilElementIsDisplayed(_scrollBar, _scrollableArea, "//div[contains(@data-test-selector, 'goal')]");
                var rowName = performancePackage.IsAutomatedGuaranteedItem ? performancePackage.DetailTabData.Name
                    : performancePackage.DetailTabData.AutoGenerateName ? performancePackage.ExpectedPackageName
                    : performancePackage.DetailTabData.Name;
                try
                {
                    rowGroup = rowGroups.First(rg => ElementContainsText(rg.FixedColumns, rowName));
                }
                catch (InvalidOperationException)
                {
                    throw new Exception($"The expected performance package '{rowName}' doesnot exist on the Media Schedule grid page");
                }

                var rowFixedColumns = rowGroup.FixedColumns;

                try
                {
                    rowFixedColumns.FindElement(By.ClassName("adslot-row"));
                }
                catch (NoSuchElementException)
                {
                    throw new Exception($"The expected performance package '{rowName} was is not an AG item'");
                }
            }

            return(true);
        }
        public bool VerifyAllSinglePlacementsExistAsAg(List <SinglePlacement> singlePlacements)
        {
            var rowGroups = GetRowGroupings("placement");

            if (singlePlacements == null || !singlePlacements.Any() || !rowGroups.Any())
            {
                throw new NotFoundException("Single placements missing in test data");
            }

            foreach (var singlePlacement in singlePlacements)
            {
                var rowName = singlePlacement.IsImportedItem ? singlePlacement.DetailTabData.Name
                    : ReplaceItemNamePlaceholderText(singlePlacement.DetailTabData.Name);

                var rowGroup = new RowGrouping();
                try
                {
                    rowGroup = rowGroups.First(rg => ElementContainsText(rg.FixedColumns, rowName));
                }
                catch (InvalidOperationException)
                {
                    throw new Exception($"The expected single placement '{rowName}' does not exist on the Media Schedule grid page");
                }

                var rowFixedColumns = rowGroup.FixedColumns;

                try
                {
                    rowFixedColumns.FindElement(By.ClassName("adslot-row"));
                }
                catch (NoSuchElementException)
                {
                    throw new Exception($"The expected single placement '{rowName} was is not an AG item'");
                }
            }

            return(true);
        }