private static int?GetSubGridItemIndexByAlias(string recordAlias, string subGridName)
        {
            var record = TestDriver.GetTestRecordReference(recordAlias);
            var index  = XrmApp.Entity.SubGrid.GetRecordIndexById(subGridName, Driver, record.Id);

            return(index > -1 ? index : default(int?));
        }
        public static void ThenTheSubgridContainsARecordWithInTheLookup(string subGridName, string alias, string lookup)
        {
            var reference = TestDriver.GetTestRecordReference(alias);

            var index = (long)Driver.ExecuteScript(
                $"return Xrm.Page.getControl(\"{subGridName}\").getGrid().getRows().get().findIndex(row => row.data.entity.attributes.get().findIndex(a => a.getName() === \"{lookup}\" && a.getValue() && a.getValue()[0].id === \"{reference.Id.ToString("B").ToUpper(CultureInfo.CurrentCulture)}\") > -1)");

            index.Should().BeGreaterOrEqualTo(0, because: "a matching record should be present in the subgrid");
        }
        private static int?GetGridItemIndexByAlias(string recordAlias)
        {
            var record = TestDriver.GetTestRecordReference(recordAlias);

            /*
             * TODO: Replace extension method with the below code when the following bug is resolved: https://github.com/microsoft/EasyRepro/issues/800.
             * var index = XrmApp.Grid.GetGridItems().FindIndex(i => i.Id == record.Id);
             */
            var index = XrmApp.Grid.GetRecordIndexById(Driver, record.Id);

            return(index > -1 ? index : default(int?));
        }