public static IControl GetColumnHeader(IControl titleRow, String headerText, TableColumnContentType contentType) { if (titleRow != null && titleRow.WebElement != null) { ReadOnlyCollection <IControl> headerCellList = SyncUtilities.FindElements_Parent(titleRow.WebElement, By.TagName("th")); foreach (IControl headerCell in headerCellList) { if (contentType == TableColumnContentType.Link) { IControl headerCellLink = SyncUtilities.FindElement_Parent(headerCell.WebElement, By.TagName("a")); if (headerCellLink.WebElement.Text.Equals(headerText, StringComparison.InvariantCultureIgnoreCase)) { return(headerCellLink); } } else { if (headerCell.WebElement.Text.Trim().Equals(headerText.Trim(), StringComparison.InvariantCultureIgnoreCase)) { return(headerCell); } } } } return(null); }
protected static void NavigateToPage(IControl tableHost, int rowNumber) { try { if (rowNumber > 0) { int rowsPerPage = 15; int pageNumber = ((rowNumber - 1) / rowsPerPage) + 1; IControl paginationControl = SyncUtilities.FindVisibleElement_Parent(tableHost.WebElement, By.ClassName("pagination")); String pageTitle = "li[title='Page :" + pageNumber + "']"; IControl pageLi = SyncUtilities.FindVisibleElement_Parent(paginationControl.WebElement, By.CssSelector(pageTitle)); if (!Control_PropertyUtilities.IsControlNull(pageLi)) { IControl pageNumberControl = SyncUtilities.FindElement_Parent(pageLi.WebElement, By.TagName("a")); if (!Control_PropertyUtilities.IsControlNull(pageNumberControl)) { Control_ActionUtilities.Click(pageLi, String.Empty); } } } } catch (Exception e) { } }
public static IControl Table_FindRow(IControl webTable, WebTable_SearchCriteriaItemList searchCreteriaItemList, int startRowIndex = 0) { IControl tableBody; if (webTable != null && webTable.WebElement != null) { if (webTable.WebElement.TagName == "tbody") { tableBody = webTable; } else { tableBody = SyncUtilities.FindElement_Parent(webTable.WebElement, By.XPath("./tbody")); } ReadOnlyCollection <IControl> rows = SyncUtilities.FindElements_Parent(tableBody.WebElement, By.TagName("tr")); for (int rowIndex = 0; rowIndex < rows.Count; ++rowIndex) { IControl row = rows[rowIndex]; if (rowIndex >= startRowIndex) { if (HasRowContainsSearchContent(row.WebElement, searchCreteriaItemList)) { return(row); } } } } return(null); }
public static IControl GetPermissionStatus(String category, String permissionName, String permissionType, out PermissionStatus permissionStatus) { permissionStatus = PermissionStatus.None; IControl c = null; if (!String.IsNullOrEmpty(category) && !String.IsNullOrEmpty(permissionName) && !String.IsNullOrEmpty(permissionType)) { category = category.Replace(" ", String.Empty); String id = "Permissions_" + category; permissionName = permissionName.Replace(" ", String.Empty); permissionName = permissionName.Replace("/", String.Empty); permissionType = permissionType.Replace(" ", String.Empty); ReadOnlyCollection <IControl> rows = SyncUtilities.FindElements(By.Id(id)); foreach (IControl row in rows) { IControl cell = SyncUtilities.FindElement_Parent(row.WebElement, By.Id(permissionName)); if (cell.WebElement != null) { return(GetCellStatus(row, permissionType, out permissionStatus)); } } } return(c); }
static IControl GetGroupsTable() { IControl mainPanel = SyncUtilities.FindElement(By.Id("mainContent")); IControl mainTable = SyncUtilities.FindElement_Parent(mainPanel.WebElement, By.Id("tblMainContent")); ReadOnlyCollection <IControl> tableList = SyncUtilities.FindElements_Parent(mainTable.WebElement, By.TagName("table")); return(new Control(tableList[0].WebElement)); }
public static ReadOnlyCollection <IControl> GetLabsTestHeaderRows() { IControl labAppDiv = SyncUtilities.FindElement(By.CssSelector("div[ng-app=labApp]")); IControl labControllerDiv = SyncUtilities.FindElement_Parent(labAppDiv.WebElement, By.CssSelector("div[ng-controller=labMainController]")); IControl grid = SyncUtilities.FindVisibleElement_Parent(labControllerDiv.WebElement, By.CssSelector("div#grid.k-grid.k-widget")); IControl headerHost = SyncUtilities.FindVisibleElement_Parent(grid.WebElement, By.CssSelector("div.k-grid-header")); IControl header = SyncUtilities.FindVisibleElement_Parent(grid.WebElement, By.TagName("thead")); return(SyncUtilities.FindVisibleElements_Parent(header.WebElement, By.TagName("tr"))); }
static bool HasImage(IWebElement cell, string value) { IControl c = SyncUtilities.FindElement_Parent(cell, By.TagName("img")); if (c != null && c.WebElement != null) { String propertyValue = c.WebElement.GetProperty("src"); return(propertyValue.Contains(value)); } return(false); }
public static IControl GetRowByRowIndex(IControl webTable, int rowIndex) { IControl tableBody = SyncUtilities.FindElement_Parent(webTable.WebElement, By.TagName("tbody")); ReadOnlyCollection <IControl> rows = SyncUtilities.FindElements_Parent(tableBody.WebElement, By.TagName("tr")); if (rows.Count > rowIndex) { return(rows[rowIndex]); } return(null); }
static int GetCurrentPageNumber(IControl pager, out IControl currentPageSpan) { IControl pageNumbersHost = SyncUtilities.FindElement_Parent(pager.WebElement, By.ClassName("k-pager-numbers")); IControl currentPageIcon = SyncUtilities.FindElement_Parent(pageNumbersHost.WebElement, By.ClassName("k-current-page")); currentPageSpan = SyncUtilities.FindElement_Parent(currentPageIcon.WebElement, By.TagName("span")); String pageNumberText = currentPageSpan.WebElement.Text; int pageNumber; Int32.TryParse(pageNumberText, out pageNumber); return(pageNumber); }
static IControl GetCellStatus(IControl row, String permissionType, out PermissionStatus permissionStatus)//,out bool found) { permissionStatus = PermissionStatus.None; //found = false; IControl c = null; IControl cell = null; ReadOnlyCollection <IControl> cells = SyncUtilities.FindElements_Parent(row.WebElement, By.TagName("td")); if (permissionType.Equals("Allow", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[2]; } else if (permissionType.Equals("Deny", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[3]; } else if (permissionType.Equals("Hide", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[4]; } else if (permissionType.Equals("View", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[5]; } else if (permissionType.Equals("Edit", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[6]; } if (cell != null) { c = SyncUtilities.FindElement_Parent(cell.WebElement, By.TagName("input")); if (c.WebElement != null) { //found = true; Boolean propStatus = c.WebElement.Enabled; if (!propStatus) { permissionStatus = PermissionStatus.Disabled; } else if (propStatus) { permissionStatus = PermissionStatus.Enabled; } } else { permissionStatus = PermissionStatus.None; } } return(c); }
static IControl GetCell(IControl row, String permissionType, out PermissionValue permissionValue)//,out bool found) { permissionValue = PermissionValue.None; //found = false; IControl c = null; IControl cell = null; ReadOnlyCollection <IControl> cells = SyncUtilities.FindElements_Parent(row.WebElement, By.TagName("td")); if (permissionType.Equals("Allow", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[2]; } else if (permissionType.Equals("Deny", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[3]; } else if (permissionType.Equals("Hide", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[4]; } else if (permissionType.Equals("View", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[5]; } else if (permissionType.Equals("Edit", StringComparison.InvariantCultureIgnoreCase)) { cell = cells[6]; } if (cell != null) { c = SyncUtilities.FindElement_Parent(cell.WebElement, By.TagName("input")); if (c.WebElement != null) { //found = true; String propValue = c.WebElement.GetAttribute("checked"); if (String.IsNullOrEmpty(propValue)) { permissionValue = PermissionValue.False; } else if (propValue.Equals("true", StringComparison.InvariantCultureIgnoreCase)) { permissionValue = PermissionValue.True; } } else { permissionValue = PermissionValue.None; } } return(c); }
public static IControl ActionPalette_GetExpandCollapseImage(IControl actionDetails) { String propertyValue = actionDetails.WebElement.GetAttribute("id"); String[] valueList = propertyValue.Split('_'); if (valueList.Length == 2) { String value1 = valueList[0]; String imageId = value1 + "_imgToggle"; return(SyncUtilities.FindElement_Parent(Sidebar.WebElement, By.Id(imageId))); } return(null); }
public static ReadOnlyCollection<IControl> GetHeaderRows() { if (IsInReferenceRangePage()) { IControl grid = SyncUtilities.FindElement(By.CssSelector("#gridReferenceRanges")); IControl headerheader = SyncUtilities.FindElement_Parent(grid.WebElement, By.CssSelector("div.k-grid-header")); IControl table = SyncUtilities.FindElement_Parent(headerheader.WebElement, By.TagName("table")); IControl header = SyncUtilities.FindElement_Parent(table.WebElement, By.CssSelector("thead")); return SyncUtilities.FindVisibleElements_Parent(header.WebElement, By.TagName("tr")); } return null; }
static bool IsEventRow(IControl row, out IControl eventNameLabel) { eventNameLabel = null; try { ReadOnlyCollection <IControl> cells = SyncUtilities.FindVisibleElements_Parent(row.WebElement, By.TagName("td")); eventNameLabel = SyncUtilities.FindElement_Parent(cells[0].WebElement, By.Id("lblEventName")); return(!Control_PropertyUtilities.IsControlNull(eventNameLabel)); } catch (Exception e) { } return(false); }
public static IControl GetMainTabHeaderInForm_NoWait(String tabHeaderText) { try { { IControl tabHeaderHost = SyncUtilities.FindElement(By.Id("divSubTabs")); IControl tabHeader = SyncUtilities.FindElement_Parent(tabHeaderHost.WebElement, By.Id(tabHeaderText)); return(tabHeader); } } catch (Exception e) { } return(null); }
public static IControl GetClickableBreadCrumbItem(IControl breadCrumbContainer, String breadCrumbItemText) { try { if (!Control_PropertyUtilities.IsControlNull(breadCrumbContainer)) { return(SyncUtilities.FindElement_Parent(breadCrumbContainer.WebElement, By.LinkText(breadCrumbItemText))); } } catch (Exception e) { new DebugLogGenerator().WriteException(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, e); } return(null); }
public static IControl GetErrorLinkToVerify(String errorText) { try { //winStudyVerifyLog IControl host = SyncUtilities.FindVisibleElement(By.CssSelector("#ctl00_ContentBody_pnlMessageLists.VerifyMessagePopupBody > table > tbody > tr:nth-of-type(2)")); if (!Control_PropertyUtilities.IsControlNull(host)) { return(SyncUtilities.FindElement_Parent(host.WebElement, By.LinkText(errorText))); } } catch (Exception e) { } return(null); }
static bool IsEventRowForFlag(IControl row, string eventName, out IControl eventNameLabel) { eventNameLabel = null; try { IControl cells = SyncUtilities.FindElement_Parent(row.WebElement, By.TagName("strong")); if (!Control_PropertyUtilities.IsControlNull(cells)) { eventNameLabel = new Control(cells.WebElement); return(!Control_PropertyUtilities.IsControlNull(eventNameLabel)); } } catch (Exception e) { } return(false); }
public static bool IsInLabManagementPage() { int i = 0; bool found = false; while (i < 10 && !found) { ++i; IControl labAppDiv = SyncUtilities.FindElement(By.CssSelector("div[ng-app=labApp]")); IControl labControllerDiv = SyncUtilities.FindElement_Parent(labAppDiv.WebElement, By.CssSelector("div[ng-controller=labController]")); IControl titleSpan = SyncUtilities.FindElement_Parent(labControllerDiv.WebElement, By.CssSelector("span[class='sptitle fl']")); if (!Control_PropertyUtilities.IsControlNull(titleSpan) && titleSpan.WebElement.Text.Equals("Manage Laboratories", StringComparison.InvariantCultureIgnoreCase)) { return(true); } Thread.Sleep(1000); } return(found); }
public static IControl GetRow(IControl webTable, int rowIndex) { IControl tableBody; if (webTable != null && webTable.WebElement != null) { if (webTable.WebElement.TagName == "tbody") { tableBody = webTable; } else { tableBody = SyncUtilities.FindElement_Parent(webTable.WebElement, By.XPath("./tbody")); } ReadOnlyCollection <IControl> rows = SyncUtilities.FindElements_Parent(tableBody.WebElement, By.XPath("./tr")); if (rows.Count > rowIndex) { return(rows[rowIndex]); } } return(null); }
public static IControl GetPageNumberControl(IControl pager, int pageNumber, out bool isCurrentPage) { isCurrentPage = false; if (pageNumber > 0) { IControl pageNumbersHost = SyncUtilities.FindElement_Parent(pager.WebElement, By.CssSelector("ul[class='k-pager-numbers']")); if (pageNumbersHost.WebElement != null) { IControl currentPageSpan = null; int currentPage = GetCurrentPageNumber(pager, out currentPageSpan); if (currentPage == pageNumber) { return(currentPageSpan); } else { return(PageNumberLink(pager, pageNumber)); } } } return(null); }
public static IControl GetAnswerFieldFromTableRow(IControl tableRow, string questionPrompt, string answerFieldType, string answerValue) { try { switch (answerFieldType.ToUpper()) { case "TEXTBOX": case "TEXT BOX": return(SyncUtilities.FindElement_Parent(tableRow.WebElement, By.XPath(".//td[contains(text(), '" + questionPrompt + "')]/parent::tr/descendant::input"))); case "LISTBOX": case "LIST BOX": IControl ListBox = SyncUtilities.FindElement_Parent(tableRow.WebElement, By.XPath(".//td[contains(text(), '" + questionPrompt + "')]/parent::tr/descendant::select")); return(new Control(ListBox.WebElement, new SelectElement(ListBox.WebElement))); case "RADIOBUTTON": case "RADIO BUTTON": case "RADIO": case "CHECKBOX": case "CHECK BOX": return(SyncUtilities.FindElement_Parent(tableRow.WebElement, By.XPath(".//label[contains(text(), '" + answerValue + "')]/preceding-sibling::input"))); case "TEXTAREA": case "TEXT AREA": return(SyncUtilities.FindElement_Parent(tableRow.WebElement, By.XPath(".//td[contains(text(), '" + questionPrompt + "')]/parent::tr/descendant::textarea"))); case "LINK": return(SyncUtilities.FindElement_Parent(tableRow.WebElement, By.XPath(".//td[contains(text(), '" + questionPrompt + "')]/parent::tr/descendant::a[contains(text(), '" + answerValue + "')]"))); case "TEXT": return(SyncUtilities.FindElement_Parent(tableRow.WebElement, By.XPath(".//td[contains(text(), '" + questionPrompt + "')]/parent::tr/descendant::span"))); } } catch (Exception e) { } return(null); }
static List <IControl> GetEventFormRows(ReadOnlyCollection <IControl> tableRows, String eventName) { List <IControl> eventFormRows = new List <IControl>(); try { bool isEventMatched = false; foreach (IControl row in tableRows) { IControl eventNameLabel = null; if (IsEventRow(row, out eventNameLabel)) { if (isEventMatched) { return(eventFormRows); } String actualEventNameOld = Control_PropertyUtilities.GetText(eventNameLabel); String actualEventNameNew = actualEventNameOld.Replace("(Select all in event)", ""); isEventMatched = eventName.Equals(actualEventNameNew.Trim(), StringComparison.InvariantCultureIgnoreCase); } else { if (isEventMatched) { IControl formRow = SyncUtilities.FindElement_Parent(row.WebElement, By.Id("lblFormRow")); if (!Control_PropertyUtilities.IsControlNull(formRow)) { eventFormRows.Add(row); } } } } } catch (Exception e) { } return(eventFormRows); }
public static IControl GetElement(IControl tableRow, String linkText, int columnIndex, TableColumnContentType contentType) { ReadOnlyCollection <IWebElement> cells = tableRow.WebElement.FindElements(By.XPath("./td")); IWebElement cell = null; if (cells.Count > columnIndex) { cell = cells[columnIndex]; } switch (contentType) { case TableColumnContentType.Image: return(SyncUtilities.FindElement_Parent(cell, By.TagName("img"))); case TableColumnContentType.Link: return(SyncUtilities.FindElement_Parent(cell, By.LinkText(linkText))); case TableColumnContentType.Link_Partial: return(SyncUtilities.FindElement_Parent(cell, By.PartialLinkText(linkText))); case TableColumnContentType.Dropdown: IControl c = SyncUtilities.FindElement_Parent(cell, By.TagName("select")); return(new Control(c.WebElement, new SelectElement(c.WebElement))); case TableColumnContentType.CheckboxAndText: case TableColumnContentType.Textbox: case TableColumnContentType.Checkbox: case TableColumnContentType.RadioButton: return(SyncUtilities.FindElement_Parent(cell, By.TagName("input"))); case TableColumnContentType.Span: return(SyncUtilities.FindElement_Parent(cell, By.TagName("span"))); default: return(null); } }
public static IControl GetExpandCollapseImage_CategoryRow(String category, out bool isExpanded) { IControl image = null; isExpanded = false; bool hasCategory = false; IControl categoryRow = GetPermissionsCategoryRow(category, out hasCategory); if (hasCategory && categoryRow.WebElement != null) { ReadOnlyCollection <IControl> cells = SyncUtilities.FindElements_Parent(categoryRow.WebElement, By.TagName("td")); if (cells.Count > 0) { IControl expandCollapseCell = cells[0]; image = SyncUtilities.FindElement_Parent(expandCollapseCell.WebElement, By.TagName("img")); if (image.WebElement != null) { String propertyValue = image.WebElement.GetAttribute("src"); isExpanded = propertyValue.Contains("collapse"); } } } return(image); }
static IControl GetTableHost_Page(String tableName, out IControl tableNameHost) { tableNameHost = null; IControl crfTabContent = SyncUtilities.FindVisibleElement(By.Id("divCRFTab")); ReadOnlyCollection <IControl> rows = SyncUtilities.FindVisibleElements_Parent(crfTabContent.WebElement, By.CssSelector("span > table > tbody > tr")); foreach (IControl row in rows) { IControl tableColumnHeaderRow = SyncUtilities.FindElement_Parent(row.WebElement, By.CssSelector("td > .ucQTable")); if (tableColumnHeaderRow != null && tableColumnHeaderRow.WebElement != null) { tableNameHost = SyncUtilities.FindVisibleElement_Parent(row.WebElement, By.CssSelector("td > table:nth-child(1)")); ReadOnlyCollection <IControl> tdList = SyncUtilities.FindVisibleElements_Parent(tableNameHost.WebElement, By.TagName("td")); foreach (IControl td in tdList) { if (Control_PropertyUtilities.GetText(td).Equals(tableName, StringComparison.InvariantCultureIgnoreCase)) { return(row); } } } } return(null); }
public static IControl Checkbox(IControl row) { return(SyncUtilities.FindElement_Parent(row.WebElement, By.CssSelector("label.k-checkbox-label"))); }
public static IControl GetFirstPageIcon(IControl pager) { return(SyncUtilities.FindElement_Parent(pager.WebElement, By.Id("SiteList_ctl00_imgPageFirst"))); }
public static IControl GetlastPageIcon(IControl pager) { return(SyncUtilities.FindElement_Parent(pager.WebElement, By.XPath("//img[@alt='Last Page']"))); }
public static IControl GetTableRowExpandCollapseElement(IControl TableRow) { return(SyncUtilities.FindElement_Parent(TableRow.WebElement, By.XPath(".//tr[contains(@id, 'lnk_rowHeader')]"))); }