public static void SelectPageAndStartProcess(string Process, int ExpectedRecordCount) { try { // check the page has rendered find the last > in the page control at the bottom of the page // this does not appear if the page count is == 1 Panel.GetEnabledElement(XpathHelper.xPath.VisiblePanel + "//div[contains(@class,'x-panel-bbar')]//button[./text()='>']", 15); } catch // (Exception ex) { // lets fail fast and move on } // get actual number of pages int actualNumberOfPages = StepHelper.SetActualNumberOfPages(); try { // lets try the last page first as it's normally here if (actualNumberOfPages > 1) { BaseComponent.WaitClick(string.Format(XpathHelper.xPath.VisiblePanel + "//button[contains(@data-pagenumber, '{0}')]", actualNumberOfPages), 15); } StartProcess(Process, ExpectedRecordCount); return; } catch { BaseComponent.WaitClick(string.Format(XpathHelper.xPath.VisiblePanel + "//button[contains(@data-pagenumber, '1')]")); // check each page starting at one for (var i = 0; i <= actualNumberOfPages; i++) { try { StartProcess(Process, ExpectedRecordCount); break; } catch (Exception Ex) { if (Ex.Message != startProcessSelectionException) { throw Ex; } // else // eat exception - should just mean it's not visisble on the page yet } // move to next page if not on the last page if (i != actualNumberOfPages) { BaseComponent.WaitClick(string.Format(XpathHelper.xPath.VisiblePanel + "//button[contains(@data-pagenumber, '{0}')]", i + 2)); } } } }
public static void PageThrough(string pageName, string sectionCaption, string columnName) { IDictionary <string, string> rowValues = new Dictionary <string, string>(); rowValues.Add(columnName, pageName + uniqueStamp); // get actual number of pages int actualNumberOfPages = StepHelper.SetActualNumberOfPages(); //lets try the last page first and revert to looping through them if the process is not on the last one if (actualNumberOfPages > 1) { BaseComponent.WaitClick(string.Format(XpathHelper.xPath.VisiblePanel + "//button[contains(@data-pagenumber, '{0}')]", actualNumberOfPages.ToString()), 5); } try { if (!Panel.SectionDatalistRowExists(rowValues, sectionCaption)) { throw new Exception (string.Format("Expected values not in the grid for Solicit code {0}.", pageName + uniqueStamp)); } } catch { //process was not on the last page lets loop through for it - move to the first page first if we are not there already try { BaseComponent.GetEnabledElement(XpathHelper.xPath.VisiblePanel + "//button[contains(@data-pagenumber, '1')]", 5); BaseComponent.WaitClick(XpathHelper.xPath.VisiblePanel + "//button[contains(@data-pagenumber, '1')]"); } catch { } // check each page - leaving this commented out as it is needed but does not need to be done right away try { for (var i = 1; i <= actualNumberOfPages; i++) { try { if (!Panel.SectionDatalistRowExists(rowValues, sectionCaption)) { throw new Exception (string.Format("Expected values not in the grid for Solicit code {0}.", pageName + uniqueStamp)); } break; } catch // (Exception Ex) { // eat exception - should just mean it's not visisble on the page yet } // move to next page if not on the last page //if (i != actualNumberOfPages) //{ // // find page number and click next page // BaseComponent.GetEnabledElement(string.Format(XpathHelper.xPath.VisiblePanel + "//button[contains(@data-pagenumber, '{0}')]", i + 2), 10).Click(); //} } } catch { } } }