protected void WaitUntilRelatedGridDisplayed(string relatedGrid, WebDriverDesktop desktop) { try { switch (relatedGrid) { case "risk": Waiter.Until(d => desktop.RiskIssuesGrid); break; case "impact": Waiter.Until(d => desktop.ScoringGrid); break; case "plan": Waiter.Until(d => desktop.PlanGrid); break; case "response": Waiter.Until(d => desktop.ResponseGrid); break; case "evaluation": Waiter.Until(d => desktop.EvaluationGrid); break; case "deficiency": Waiter.Until(d => desktop.DeficiencyGrid); break; case "documents": Waiter.Until(d => desktop.DocumentGrid); break; case "audits": Waiter.Until(d => desktop.AuditGrid); break; case "incidents": Waiter.Until(d => desktop.IncidentGrid); break; default: throw new WebDriverException("Unknown grid type unable to wait for grid to be displayed check grid type implemented - " + relatedGrid + ". "); } } catch (WebDriverTimeoutException ex) { throw new WebDriverTimeoutException("Timed out while waiting for the related grid " + relatedGrid + ", to be displayed. " + ex); } }
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 + "."); } } } }