public void ClickOnCellofRecordWithTitle(string recordTitle, string recordType, string cellToClick)
        {
            var records      = Element.FindElements(By.CssSelector(GridLocators.GridRow));
            var recordsCount = Element.FindElements(By.CssSelector(GridLocators.TitleColumnLocator)).Where(d => d.Text.Equals(recordTitle)).ToArray().Length;

            if (recordsCount == 0)
            {
                throw new WebDriverException(recordType + ": " + recordTitle + " Not Found in " + recordType + " Grid. Unable to click on requested cell.");
            }
            if (recordsCount > 1)
            {
                throw new WebDriverException("More than one record with the title " + recordTitle + " found on the " + recordType + " grid. Found " + recordsCount + " records. Unable to determin which record requested.");
            }

            foreach (var record in records)
            {
                if (record.FindElement(By.CssSelector(GridLocators.TitleColumnLocator)).Text.Equals(recordTitle))
                {
                    var itemToClick = record.FindElements(By.CssSelector(GridLocators.GridCellSelector(cellToClick)));
                    if (itemToClick.Count != 1)
                    {
                        throw new WebDriverException("Cell to click not found or more than one option found, looking for cell " + cellToClick + ". Found " + itemToClick.Count + ".");
                    }
                    itemToClick[0].Click();
                    break;
                }
            }
        }
        public string GetValueOfCellForRecordWithTitle(string recordTitle, string recordType, string cell)
        {
            var records      = Element.FindElements(By.CssSelector(GridLocators.GridRow));
            var recordsCount = Element.FindElements(By.CssSelector(GridLocators.TitleColumnLocator)).Where(d => d.Text.Equals(recordTitle)).ToArray().Length;

            if (recordsCount == 0)
            {
                throw new WebDriverException(recordType + ": " + recordTitle + " Not Found in " + recordType + " Grid. Unable to get requested value.");
            }
            if (recordsCount > 1)
            {
                throw new WebDriverException("More than one record with the title " + recordTitle + " found on the " + recordType + " grid. Found " + recordsCount + " records. Unable to determin which record was requested.");
            }

            foreach (var record in records)
            {
                if (record.FindElement(By.CssSelector(GridLocators.TitleColumnLocator)).Text.Equals(recordTitle))
                {
                    var cellToGet = record.FindElements(By.CssSelector(GridLocators.GridCellSelector(cell)));
                    if (cellToGet.Count != 1)
                    {
                        throw new WebDriverException("Cell to get not found or more than one option found, looking for cell " + cell + ". Found " + cellToGet.Count + ".");
                    }
                    return(cellToGet[0].Text);
                }
            }
            throw new WebDriverException("Failed to get cell value on the grid, method exited unexpectedly.");
        }
        public void OpenRelatedGridByRecordTitle(string currentRecordType, string relatedRecordType, string recordTitle, WebDriverDesktop desktop)
        {
            var recordsCount = Element.FindElements(By.CssSelector(GridLocators.TitleColumnLocator)).Where(d => d.Text.Equals(recordTitle)).ToArray().Length;

            if (recordsCount > 1)
            {
                throw new WebDriverException("More than one record with the title " + recordTitle + " found on the " + currentRecordType + " grid. Found " + recordsCount + " records. Unable to determin which record to open.");
            }
            if (recordsCount == 0)
            {
                throw new WebDriverException("No records with the title " + recordTitle + " found on the " + currentRecordType + " grid.");
            }

            var records = Element.FindElements(By.CssSelector(GridLocators.GridRow));

            foreach (var record in records)
            {
                if (record.FindElement(By.CssSelector(GridLocators.TitleColumnLocator)).Text.Equals(recordTitle))
                {
                    var gridIcon = record.FindElements(By.CssSelector(GridLocators.RelatedGridSelector(relatedRecordType)));
                    if (gridIcon.Count == 0)
                    {
                        throw new WebDriverException("Related record icon not found on grid. Looking for related grid " + relatedRecordType + " on the " + currentRecordType + " grid, for the record " + recordTitle + ".");
                    }
                    if (gridIcon.Count == 1)
                    {
                        gridIcon[0].Click();
                        WaitUntilRelatedGridDisplayed(relatedRecordType, desktop);
                        break;
                    }
                    if (gridIcon.Count > 1)
                    {
                        throw new WebDriverException("Something is wrong found multiple grid icons, found " + gridIcon.Count + " icons for related grid " + relatedRecordType + " on the " + currentRecordType + " grid, for the record " + recordTitle + ".");
                    }
                }
            }
        }