Skip to content
Amol Dakhane edited this page Mar 2, 2017 · 24 revisions

Note: Documentation is still in progress and not complete

Welcome to the SampleSeleniumPOMFramework wiki! This framework is designed to kick start automation in any team,using Selenium Webdriver and C# with NUnit 2.6.4. framework. It is designed using Selenium Page Object model(POM) concept.

Frame work Components:

Please refer below image for framework components

  • Selenium WebDriver Utilities: This module has around 50+ generic methods to interact with UI elements All these methods can be readily used by any project. E.g. NavigateToURL( ), Click( ), GetText( ) etc..

  • Application Page Repository (POM): It has various class pages with UI elements and corresponding methods for various pages in web application

Framework Components

  • Test Classes and Cases: This component has various test classes and cases for entire application

  • Unit Testing Framework (nUnit): This is used to write verification points such as Assert statements and Collection Assert statements

  • Data Sources and Data Files: It has various data sources definitions and data files(.CSV) for data driven testing

  • Configuration Files: Configuration XML for browser and environment specifications

  • Exception Handling: This provides continued execution of long running suites even though some test cases throws some unexpected errors

  • Service References: This module provides integration with various services, using this data can be read from services directly and verified on application as per test cases

  • Batch Files: Batch files for running Smoke and Regression categories of test cases which helps running automation without using any Test runner or tool.

  • Report Generator: Report Generator exe, which can be used to generate the summary report from NUnit xml output

  • SpecFlow Integration: In case required in future, using this module, test cases can be easily migrated to spec flow.

Folder Structure:

Please refer following image for folder structure and explanation for respective folders

Folder Structure

Reusable Methods: I have also written some reusable methods, which can be very useful. Which are available in SeleniumUtilities.dll and which is also referred in the references. This dll contains lots of regularly used methods. Below is the list for the same(This list will be updated from time to time as on when I add new methods)

  `  public static string dateTimeStamp { get; }`
    `public static void AcceptAndCloseAlert();`
    `public static Actions ActionBuilder();`
    `public static void ClearTextIgnoringStaleElementException(IWebElement Element, int numberOfTries = 5);`
    `public static void ClickOnCellTextFromTable(string txtTOBeClicked);`
    `public static void ClickOnElement(By locator);`
    `public static void ClickOnElementIgnoringStaleElementException(IWebElement Element, int numberOfTries = 5);`
    `public static void ClickOnSpecificCellFromTable(By tableIdentifier, int rowIndex, int colIndex);`
    `public static string CloseAlertAndGetItsText();`
    `public static void DragAndDrop(IWebElement sourceElement, IWebElement destinationElement);`
    `public static SelectElement Dropdown(By selectDrpDwnLocator);`
    `public static SelectElement Dropdown(IWebElement element);`
    `public static void EnterText(By locator, string requiredText);`
    `public static void EnterTextIgnoringStaleElementException(IWebElement Element, string text, int numberOfTries = 5);`
    `public static IWebElement FindElement(By locator);`
    `public static List<string> GetAllItemsToStringList(List<IWebElement> allElements, string textFromWhereToTrim = "AmolDakhane");`
    `public static List<string> GetAllItemsToStringListExcludingBlank(By locator, string textFromWhereToTrim = "AmolDakhane");`
    `public static string GetAttributeValue(By locator, string attributeName);`
    `public static List<IWebElement> GetCollection(By locator);`
    `public static List<string> GetCollectionFromPageToStringList(By locator, string textFromWhereToTrim = "AmolDakhane");`
    `public static List<string> GetCollectionFromPageToStringListWit(By locator, string textFromWhereToTrim = "AmolDakhane");`
    `public static List<IWebElement> GetCollectionToList(By locator);`
    `public static int GetIndexOfRowContainingSpecificText(By locatorForRows, string stringToBeSearched);`
    `public static int GetIndexOfTableRowContainingSpecificText(By tableIdentifier, string stringToBeSearched);`
    `public static List<string> GetIwebElementTextToStringList(By locator);`
    `public static int GetNumberOfRowsInTable(IWebElement tableElement);`
    `public static int GetNumberOfRowsInTable(By tableLocator);`
    `public static string GetText(By locator);`
    `public static string GetValueFromSpecificCellFromTable(IWebElement tableIdentifier, int rowIndex, int columnIndex);`
    `public static string GetValueFromSpecificCellFromTable(By tableIdentifier, int rowIndex, int columnIndex);`
    `public static List<string> GetValuesOfColumnFromTable(IWebElement tableIdentifier, string columnName);`
    `public static List<string> GetValuesOfSpecificColumnFromTable(By tableIdentifier, int columnNumber);`
    `public static List<string> GetValuesOfSpecificColumnFromTable(IWebElement tableIdentifier, int columnNumber);`
    `public static void HandleNotNullInnerException(Exception exp);`
    `public static void HandleNullInnerException(Exception exp);`
    `public static void ImplicitWait(int seconds);`
    `public static bool IsAlertPresent();`
    `public static bool IsElementPresent(By by);`
    `public static bool IsElementPresent(IWebElement element);`
    `public static void JsClick(string identifier);`
    `public static IJavaScriptExecutor JsExecutor();`
    `public static void JsScrollTillEnd();`
    `public static void JsScrollToTop();`
    `public static void LoginWithDifferentUser(string siteUrl, string domainName, string userName, string passWord);`
    `public static void ManageFailure(Exception exp);`
    `public static void MoveCursor(int Xcoordinate, int Ycoordinate);`
    `public static void NavigateToURL(string url);`
    `public static void PrintStringList(List<string> listName);`
    `public static void SelectFromDrpDwnIgnoringStaleElementException(IWebElement Element, string option, int numberOfTries = 5);`
    `public static void SelectFromListDropDown(IList<IWebElement> IWebElementsCollection, string itemName);`
    `public static void SelectFromListDrpDwnIgnoringStaleElementException(IList<IWebElement> IWebElementsCollection, string itemName, int numberOfTries = 5);`
    `public static void SetfocusAndClickOnIWebElement(IWebElement element);`
    `public static void SetfocusOnIWebElement(IWebElement element);`
    `public static void Setup();`
    `public static List<string> SplitEachItemInStringCollectionAndAddtoList(List<string> collection, string[] splitByCharacter);`
    `public static void SwitchToDilog();`
    `public static void SwitchToWindow(Expression<Func<IWebDriver, bool>> predicateExp);`
    `public static string TakeScreenshot();`
    `public static void Teardown();`
    `public static WebDriverWait Wait();`
    `public static void WaitForElementIsClickable(By locator, int seconds = 30);`
    `public static void WaitForElementIsClickable(IWebElement element, int seconds = 30);`
    `public static void WaitForElementToGetInVisible(By locator, int seconds = 30);`
    `public static void WaitForElementVisible(By locator, int seconds = 30);`