Git Product home page Git Product logo

basic-selenium-project's Introduction

N|Solid

basic-selenium-project

This project is written in java and will serve an example of implementing a Selenium test project with Selenium3 and Maven. Everything is set up and tests can be added straight away. Used Testrunner is the Failsafe plugin. To execute the tests just browse to the path where the basic-selenium-project is located in your terminal and type mvn clean verify -Pbrowser-chrome or execute the tests in your IDE. maven profiles for all browsers exists in the pom.xml.

If you want to make template tests that doesn't need browser interactions like clicking or execution of Javascript just have a look at Paco Framework. It's much much faster then Selenium and less fragile.

Implemented Browsers

Thanks to the awesome webdrivermanager it supports the following browsers and automatically downloads OS specific binaries for:

  • Chrome
  • Firefox
  • PhantomJS
  • Opera
  • Internet Explorer
  • Edge

The Webdriver Setup

The webdriver setup is based on the WebDriverBuilder and the DesiredCapabilitiesFactory to have a separation between driver instantiation and browser specific settings.

Page Objects Pattern

page object pattern is used to have reusable WebElements/small helper methods seperated from actual test classes and give the opportunity to have nice structured and easily readable tests (without the overhead of BDD-Frameworks like Cucumber or JBehave).

Annotations

Beside a bunch of [Convenient Methods] the basic-selenium-project provides some nice custom annotations to comfortably set some test conditions and/or assumptions Example test that uses several annotations: SearchIT.java

@Browser

The @Browser annotation includes or excludes certain browsers from the test execution

skip test if browser equals firefox:

@Browser(skip = FIREFOX)

it also supports list of browsers, e.g. skip test if browser equals firefox or phantomjs

@Browser(skip = { FIREFOX, PHANTOMJS })

it can be used the other way around as well e.g. if you want a certain test just to be executed with phantomjs you can do something like this:

@Browser(require = PHANTOMJS)

The browser require option is working equivalent to the skip option and also supports list of browsers

@BrowserDimension

If you want to test a responsive website it can be handy to set the browsers to some specific viewports. To configure your breakpoints just edit them in the test_data.properties

Resizing the browser window for specific tests can be done by e.g.:

@BrowserDimension(LARGE)

@UserAgent

UserAgents can be overwritten and give the possibility to emulate the behaviour of an website if special devices visiting it. For Example if you want to test a mobile switch for devices like smartphones and/or tablets etc.

@UserAgent(IPHONE_I_OS_9)

There already is a list of user agents in the UserAgents Enum. All user agents located in that file will can be used with @UserAgent

Convenient Methods

you can find a couple of convenient methods like waits, isElementPresent/Visible, hover, dragAndDrop, etc. in SeleniumFunctions.java as well as helper methods for cookie, localstorage and sessionstorage handling. Example tests that do some stuff with cookies and do some stuff with localstorage/sessionstorage are added and should show the the usage self-evident.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.