GithubHelp home page GithubHelp logo

dutchb / tech-test-selenium-jbehave Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kowalcj0/tech-test-selenium-jbehave

0.0 0.0 0.0 207 KB

Simple project based on the JBehave tutorial, that uses Java with Spring, Selenium WebDriver and JBehave to drive the BDD user stories

Java 100.00%

tech-test-selenium-jbehave's Introduction

A JBehave Selenium tutorial project

Simple project based on the JBehave tutorial available at github You can use this example project to build your own JBehave-based testing solution.

Project structure

  1. src/main/java/tech/test/Stories.java is the entry-point that JBehave uses to run the stories.
  2. src/main/stories contains the stories run by JBehave via Stories.java.
  3. src/main/java/tech/test/steps/Steps.java contains the steps mapped to the textual steps.
  4. src/main/java/tech/test/pages contains the Java page-objects used by steps to abstract in a more manageable and maintainable way the interaction with the web pages via Selenium WebDriver.
  5. src/main/resources/techtest-steps.xml contains the Spring configuration for composition the steps

Prerequisites

  • JDK 6+
  • Maven 2+
  • Firefox 10+

Windows configuration

Once all the required tools are installed:

  • create two new system variables:

    • JAVA_HOME e.g.: JAVA_HOME=C:\Program Files\Java\jdk1.7.0_10
    • M2_HOME e.g.: M2_HOME=C:\Program Files\apache-maven-3.0.5
  • add paths to the firefox, java and maven folders containing corresponding binaries to the Path variable, e.g.:

    Path=WHATEVER_WAS_THERE_BEFORE;C:\Program Files\Java\jdk1.7.0_10\bin;C:\Program Files\apache-maven-3.0.5\bin;C:\Program Files (x86)\Mozilla Firefox\

NOTES:

  • More information on [FirefoxDriver] 1
  • Handy tutorial on setting $PATH and environmental variables in Windows.
  • FF binary (firefox.exe) can usually be found in %PROGRAMFILES%\Mozilla Firefox

Linux configuration

Is similar to Windows one. Simply make sure that:

  • JAVA_HOME and M2_HOME system variables are properly set.
  • folder with Firefox binary is in your $PATH system variable

NOTES:

  • More information on [FirefoxDriver] 1
  • Handy tutorial on setting $PATH and environmental variables under *nix systems.
  • Another one just on setting up the java path variable.
  • FF binary can be found using "which" command.

Mac configuration

Same thing as with Windows and Linux You need to make sure that:

  • JAVA_HOME and M2_HOME are set accordingly
  • folder with Firefox binary is in your $PATH system variable

NOTES:

  • More information on [FirefoxDriver] 1

  • Here's a nice tutorial on setting $PATH and environmental variables in Mac.

  • Usually FF binary (filename is firefox-bin) is placed in:

    /Applications/Firefox.app/Contents/MacOS/

Add a new user story

Create a new text file with '.story' extension in the src/main/stories folder. Then write down the body of the user story you want to run.

Running all the stories in IDE

IntelliJ Idea 12

  • Right-click on the Stories class, select "Run 'Stories'"

Eclipse EE Juno SR2 with M2E plugin v1.3.0

  • Right-click on the Stories class, select "Run as" -> "JUnit Test"

Running a single story in IDE

Go to the 'RunSingleStory.java' method 'runTest' and change the name of the user story you want to run. Remember that the story name has to be exactly the same as the story filename but without the '.story' extension.

After that in:

IntelliJ Idea 12

  • Right-click on the RunSingleStory class, select "Run 'RunSingleStory'"

Eclipse EE Juno SR2 with M2E plugin v1.3.0

  • Right-click on the RunSingleStory class, select "Run as" -> "JUnit Test"

Running stories from the command line

This will run the build and (after a minute or so) Firefox will open and run your tests against the yell.com website:

mvn clean install

This will run a single story (one contained in a searchFromHomePage.story file):

mvn clean install -DstoryFilter=searchFromHomePage

This will run a suite based on the meta filters in the three story files:

mvn clean install -Dmeta.filter="+page home"

Viewing the results

After each run new report can be found in target/jbehave/view. Report file is named: 'reports.html' There should be a row for each story. The story reports are clickable to via links on the right-most column.

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.