Email: [email protected]
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.
- 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.
<dependency> <groupId>com.jivesoftware</groupId> <artifactId>jive-selenium-pages-framework</artifactId> <version>1.0.6</version> </dependency>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.
// 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 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 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.