Supporting notes and handouts for our Getting Started Online Course

This post supports our free online Get Started With Selenium WebDriver Using Maven, IntelliJ and Java Course

These notes are not ‘instead of’ working through the course. They are a supporting handout with the main links used in the course. But might help someone as a stand alone set of notes.

A cheat sheet, in other words.

Microsoft Virtual PC Compatibility Images

This should be your first stop http://www.modern.ie/en-us

For older machines using Virtual PC

 

Install Browser and Plugins

Firefox http://www.getfirefox.net/

  • Firebug
  • FirePath
  • FireCookie – no longer required as the functionality is now part of firebug

Optionally Install Utility Tools

You do not need these, but I use them in the videos to make it easier to see what is going on.

Install Java SDK

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Install Maven

Maven – http://maven.apache.org/

http://maven.apache.org/download.html#Installation

The instructions on the official maven home page work for XP and 2000 but not for Windows 7

The video is correct and there is a summary of the steps I took here

Install IntelliJ

IntelliJ http://www.jetbrains.com/idea/

Optionally Install Ant and Eclipse

Only if you are using these in your environment. I cover Maven and IntelliJ

Ant the easy way http://code.google.com/p/winant/

Eclipse http://www.eclipse.org/

A simple project using Maven

Selenium maven info
http://seleniumhq.org/download/maven.html

Junit maven info
http://maven.apache.org/plugins/maven-surefire-plugin/examples/junit.html

Running your maven tests

The next few sections cover running your tests through maven.

Running your maven tests from the command line

in windows explorer shift+right click

mvn test

For more info on maven see http://maven.apache.org/users/index.html

The IDEs have plugins for this too…

Running maven from IntelliJ

use maven plugin on right

Running maven from Eclipse

I would have loved to create an easy this is how to run it from Eclipse, but I found it hard to figure out how to configure eclipse to do it. Partly why I use IntelliJ with Maven. (The video on the course shows how I did it)

It should be as simple as right click on pom.xml “Run As…”

But I had config issues. Other people have encountered it too.

http://maven.40175.n5.nabble.com/Unable-to-locate-the-Javac-Compiler-Problem-td133804.html

http://stackoverflow.com/questions/5163021/how-to-resolve-this-maven-issue

Having said that… I tend to use maven from the command line when working with Eclipse. And use the IDE for creating and running single tests.

Making command line easier

You can use a variety of tools to make command line work easier.

Use of Console2

Create a folder for your code and cmd.exe open at folder. Simple.

C:\Users\Administrator\workspace\selenium_mvn_eclipse

C:\Users\Administrator\IdeaProjects\MyFirstSeleniumIntelliJMaven

Consider ConEmu

http://code.google.com/p/conemu-maximus5/

ConEmu is a little more complicated (a lot) but much more powerful, if you have the time then investigating ConEmu may pay dividends. I’m still learning it.

http://www.hanselman.com/blog/ConEmuTheWindowsTerminalConsolePromptWeveBeenWaitingFor.aspx

Ant

For ant we need to download the webdriver Jar and create a build.xml file

WebDriver & Selenium
http://seleniumhq.org/download/

A simple project with Eclipse using Ant

  • Download selenium server standalone jar (seleniumhq.org/download)
  • Create directory libs
  • Create directory for selenium_2.25.0
  • Download junit jar (junit-4.10.jar)
  • Add to project
  • create ant file
<?xml version="1.0"?>
<project name="Run Selenium Tests" default="run_all">

<!-- Sets variables which can later be used. -->
 <!-- The value of a property is accessed via ${} -->
 <property name="src" location="src" />
 <property name="target" location="target" />
 <property name="libs" location="libs" />
 <property name="testresults" location="junit-results" />
 <property name="testreport" location="junit-report" />
<!-- default Selenium version to use by build script, override from command line
 e.g. ant -f buildfile.xml -DseleniumVersion=2.1.0 
 double check and adjust if necessary for each new version of Selenium
 -->
 <property name="seleniumVersion" value="2.25.0" />
 
 <!-- use a regular naming convention for the folder to make things easy
 so all selenium versions go in lib/selenium_<versionnumber> 
 -->
 <property name="seleniumLibsFolder" value="selenium_${seleniumVersion}" />
 <property name="seleniumclient" location="${libs}/${seleniumLibsFolder}/selenium-java-client-driver.jar" /> 
 <property name="seleniumserver" location="${libs}/${seleniumLibsFolder}/selenium-server-standalone-${seleniumVersion}.jar"/>
 
 <!-- Define the classpath which includes the junit.jar and the classes after compiling-->
 <path id="junit.class.path">
 <pathelement location="${libs}/junit-4.10.jar" />
 <pathelement location="${seleniumclient}" />
 <pathelement location="${seleniumserver}" />
 <pathelement location="${build}" />
 </path>
 <!-- Deletes the existing build and result directories-->
 <target name="clean">
 <delete dir="${build}" />
 <delete dir="${testresults}" />
 <delete dir="${testreport}" />
 </target>
 
 <!-- Creates the build, and test results directories-->
 <target name="makedir">
 <mkdir dir="${build}" />
 <mkdir dir="${testresults}" />
 <mkdir dir="${testreport}" />
 </target>
<!-- Compiles the java code -->
 <target name="compile" depends="clean, makedir">
 <javac srcdir="${src}" destdir="${build}" debug="true" includeAntRuntime="false">
 <classpath refid="junit.class.path" />
 </javac>
 </target> 
 
 
 <target name="report-junit">
 <junitreport todir="${testreport}">
 <fileset dir="${testresults}">
 <include name="TEST-*.xml"/>
 </fileset>
 <report format="frames" todir="${testreport}"/>
 </junitreport>
 </target>
 
 <target name="run_all" depends="compile">
 <junit printsummary="yes" fork="yes" errorproperty="junit.error" failureproperty="junit.error">
 
 <classpath refid="junit.class.path" />
 <formatter type="xml" />
 
 <!-- run everything in the com.eviltester.webdriver package -->
 <batchtest todir="${testresults}">
 <fileset dir="${build}" includes="com/eviltester/webdriver/*.class" />
 </batchtest> 
 
 </junit>
 <antcall target="report-junit"/>
 <fail if="junit.error" message="Selenium test(s) failed. See reports!"/>
 </target> 
 
</project>
This entry was posted in Courses, Selenium Simplified Blog. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *