Skip to content

3vz/getting-started-with-selenium

 
 

Repository files navigation

star fork

Getting Started

To get right up and started, you can download the project (zip) or you can checkout the project from github. If you don't know how, this should help.

Prerequisites

  • Maven (if using eclipse, install Maven Integration for Eclipse)
  • jUnit 4
  • Java
  • WebDriver (Chrome, Firefox, IE, etc)

Drivers

Currently, not all drivers are not packaged with this project, but they may be in the future!

  • Chromedriver (now is packaged with the project)
  • Firefox driver IS actually packaged with the Selenium jar.
  • IEDriver

Launch your IDE, and under src/tests/java you'll find a file under the functional package. This is a very short a simple test. If you do not have Chromedriver installed, just switch the browser to FIREFOX and right click the file and Run As -> jUnit Test

Goals

The primary goals of this project are to...

  • Take advantage of method chaining, to create a fluent interface.
  • Abstract the programmer from bloated scripts resulting from using too many css selectors, and too much code.
  • Provide a quick and easy framework in Selenium 2 using Java, to get started writing scripts.
  • Provide a free to use framework for any starting enterprise, or individual programmer.
  • Utilize the power of CSS!

Actions

You can perform any action that you could possibly do, using the inline actions.

  • click(By)
  • setText(By, text)
  • getText(By)
  • hoverOver(By)
  • check(By)
  • uncheck(By)
  • navigateTo(url)
  • goBack()
  • isPresent(By)
  • getAttribute(By, attribute)
  • etc.

In-line validations

This is one of the most important features that I want to accentuate.

  • validateText
  • validateTextNot
  • validateChecked
  • validateUnchecked
  • validatePresent
  • validateNotPresent
  • validateTextPresent
  • validateTextNotPresent

All of these methods are able to be called in-line, and fluently without ever having to break your tests.

Switching Windows

Another nice feature that is offered, is the simplicity of window switching in Selenium.

  • switchToWindow(regex)
  • waitForWindow(regex)
  • closeWindow(regex)

All of these functions take a regular expression argument, and match either the url or title of the window that you want to interact with.

Switching Frames

  • switchToFrame(idOrName)
  • switchToDefaultContent()

Implicit Waiting

In addition to the Selenium 2 implicit waiting, the AutomationTest class extends on this concept by implenting a sort of waitFor functionality which ensures that an object appears before interacting with it. This rids of most ElementNotFound exceptions that Selenium will cough up.

See a working example of what a test script written using this framework might look like.

Pull requests

If you have an idea for the framework, fork it and submit a pull-request!

About

The Selenium API that will get you started.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published