vik542 / jive-selenium-pages-framework

This repository provides a framework for automated Selenium testing. The framework simplifies the configuration of WebDrivers by providing a facade called a Browser, and LocalBrowserBuilder, RemoteBrowserBuilder for easily creating Browsers. Also provides a Page abstraction for modeling web pages of your webapp for testing. This provides an object-oriented approach to testing a web app, where the basic building blocks are SubPages (i.e. re-usable components of a web page) and TopLevelPages (i.e. a web page at a specific URI).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jive-selenium-pages-framework

Jive Selenium Pages Framework

Author: Charles Capps

Contact Email: qa.automators@jivesoftware.com

Javadoc can be found here

This framework provides many valuable features for simplifying Selenium Browser testing. The framework has been used internally at Jive Software with much success. It simplifies the configuration and creation of Selenium WebDrivers for different browsers. The framework also provides a Page abstraction for modeling your webapp's pages.

Key Features:

Browser configuration and instantiation

  • The Browser classes provide a facade for configuring and using Selenium WebDrivers.
  • Use LocalBrowserBuilder.getBuilder() or RemoteBrowserBuilder.getBuilder() to instantiate a Chrome, Firefox, or Internet Explorer Browser that is either on the local machine or running in a Selenium Grid.
  • Methods such as saveScreenshotToFile() are helpful utilities for interacting with the Browser.
  • After you have a browser, call browser.getActions() to get an instance of SeleniumActions.

Adding jive-selenium-pages-framework as a dependency

This project is in the Maven Central Repository, so if your project uses maven you can just add this as a dependency with:
    <dependency>
        <groupId>com.jivesoftware</groupId>
        <artifactId>jive-selenium-pages-framework</artifactId>
        <version>1.0.10</version>
    </dependency>

Building

This project uses maven. For maven, you must have JAVA_HOME set to a valid Java installation of Java7 or above. As long as you have maven 3.0.5 or above installed and Java7 or above, then you should be able to execute the following:
mvn clean install -DskipTests

to install a new version to your local repo. You can then use it by adding the version you installed to the POM of any local project.

Sample code creating a Browser instance (Chrome)

    // Create a TimeoutsConfig instance. You can also just use TimeoutsConfig.defaultTimeoutsConfig().
    TimeoutsConfig timeouts = TimeoutsConfig.builder()
        .clickTimeoutSeconds(2)                  // Timeout waiting for a WebElement to be clickable (used by the framework)
        .webElementPresenceTimeoutSeconds(5)     // Timeout when polling for a web element to be present (or visible, depending on the method)
        .pageLoadTimoutSeconds(10)               // Timeout waiting for a new page to load (used by the framework, and to configure underlying WebDriver).
        .implicitWaitTimeoutMillis(2000)         // Implicit wait timeout used by the underlying WebDriver.
        .build();

    // Create a ChromeBrowser
    Browser browser = LocalBrowserBuilder.getChromeBuilder("http://my.webapp.com/webapp")  // Base URL for testing. 
                           .withTimeoutsConfig(timeouts)             // TimeoutsConfig created above.
                           .withBrowserLocale(Locale.US.toString())  // Browser locale
                           .withStartWindowWidth(1280)               // Starting width for the browser window in pixels
                           .withStartWindowHeight(1024)              // Starting height for the browser window in pixels
                           .withBrowserLogLevel(Level.INFO)          // Logging Level for the WebDriver's logs
                           .withBrowserLogFile("chromedriver.log")   // Path to logfile, only supported for Chrome and IE. 
                           .build();
                           
     // Load a web page
     TopLevelPage googleHomePage = browser.openPageByUrl("http://google.com");

SeleniumActions

  • SeleniumActions are for interacting with the DOM and javascript of a page.
  • Obtain a SeleniumActions from a Browser instance with browser.getActions()
  • Provides methods for waiting until a WebElement is present or visible.
  • Provides methods to refresh the page until a WebElement is present or visible.
  • Provides methods for finding a WebElement containing specific text.
  • Provides methods for interacting with Tiny MCE text editors.
  • Provides methods to load Pages.
  • Provides much more functionality.

Pages

  • Pages provide an abstraction for modeling the pages for your webapp.
  • Pages should extend BaseTopLevelPage or BaseSubPage.
  • Uses the Selenium @FindBy annotation to instantiate member variables that are WebElements.
  • Use the annotation @SubPageField to indicate a member variable that is a SubPage and should be instantiated on page load.
  • Model the actions that you can perform on your web pages in your Page classes.
  • Then, test code is incredibly simple. It just delegates to Page classes and performs high-level actions.

About

This repository provides a framework for automated Selenium testing. The framework simplifies the configuration of WebDrivers by providing a facade called a Browser, and LocalBrowserBuilder, RemoteBrowserBuilder for easily creating Browsers. Also provides a Page abstraction for modeling web pages of your webapp for testing. This provides an object-oriented approach to testing a web app, where the basic building blocks are SubPages (i.e. re-usable components of a web page) and TopLevelPages (i.e. a web page at a specific URI).


Languages

Language:Java 100.0%