Learn Selenium WebDriver Online On Our New Training Platform

Over the last few days we have been busy uploading the Selenium 2 WebDriver with Java course to a new platform, and now we are having a ‘Grand Opening Sale’.

Join our Course for only $175 with coupon self175

The new platform is clean, simple and, probably most important for you – cheaper for us. So we can pass on the cost savings to you.

As part of our ‘Grand Opening’ we have dropped the price of the course from the $299 that it sells for on other sites to $175.

The course is the same as we host on other training platforms, and we will keep all versions of the course in step with each other.

Use the code ‘self175‘ and, instead of paying $299, you can start learning WebDriver at your own pace for only $175.

The new site lets you watch previews of the videos without needing an account, so you can check how well the teaching style works for you.

We will add other courses so make sure you sign up for our mailing list and we will keep you up to date.

Posted in Uncategorized | Leave a comment

Updated the Getting Started With Selenium WebDriver free course

I just updated the Getting Started with Selenium WebDriver free course.

Mainly because IntelliJ 13 has been confusing some people starting out – my main install videos showed IntelliJ 12 and 11.

Also, Maven has proven more troublesome than expected. For something that in theory seems easy. In practice, many people (including myself) have issues creating the environment variables and the path.

Fortunately, when I created the new version. I also experienced install issues, so the video shows the problem “typing ‘mvn -version’ and windows not finding it” followed by my thinking through the problem with a fix.

I also created the videos without using the Rapid Environment Editor, as the introduction of another tool seemed to confuse some people. Which was never the aim, so I removed it from the main video.

I amended the following videos:

 

Posted in Maven, Training Courses | Leave a comment

Problems running WebDriver on Firefox 26?

The Issue

I had a quick look at version 26 of Firefox today, because a fair few people contacted me, saying they had been having issues with it.

Based on forums and calls for help, these people weren’t the only ones.

But, not everyone is experiencing the problem, so there is something odd going on.

I could experience the problem on my main Windows 8 machine, but I hadn’t noticed, because I hadn’t upgraded to version 26 of Firefox.

First the Workaround

The fix I used was to downgrade my version of firefox to 25.0.1

And WebDriver worked fine for my basic test, I tried WebDriver versions 2.38.0 up to version 2.40.0.

I installed Firefox version 27.0b2, and it failed with the same problem I experienced with version 26.

I don’t know the root of the problem I’m experiencing, but my workaround will be to stick on Firefox 25 for my automation work.

Remember to use the Firefox Options \ Upgrade, and set it to not upgrade.

The Salutary Lesson

This might seem extreme, but when doing automation, we need to control the versions of software we test with. If you allow your browser to automatically update without your knowledge then you don’t know if your automation fails because of something you did, or something environmental.

Control of your environment means that when a problem happens, it is most likely something you did.

Given that other people have managed to get WebDriver working with Firefox 26. It might be an operating system based issue, or a plugin issue, or a heaven-knows-what issue.

Summary

When faced with problems like these:

  1. Check if anyone else is having the problem
  2. Did anyone find a solution? Try it.
  3. Find a workaround. (First try downgrading to a known working state)
  4. Investigate roll forward options

If execution against version 26 is important to you, try running Firefox on a VM with a different operating system, perhaps from modern.ie. Or try running against Saucelabs.

But DO. DO keep control of your execution environments and the software versions running on them.

Posted in Firefox, WebDriver | 14 Comments

Question: Do you use WebDriverWait instead of Asserts?

I watched some of your lectures and webinars and it looks like you are using WebDriverWait partly as a substitute for assertions. Is that normal?

WebDriverWait will throw an exception if it can’t find the item. Which has a similar effect to an Assert i.e the @Test will fail. I do not view this as an assert, I view this as setting up the necessary preconditions for the test, rather than a specific ‘check’ that the @Test enforces.

I explicitly use Asserts when the Assert describes something important for the test. So when people read the test they know what I am ‘testing for’.

Sometimes I add an Assert after a WebDriverWait, even though I know the Assert will never be thrown if the WebDriverWait fails, because in the context of the code, the Assert documents something important for the test.

I do not create tests without Asserts in production, even if a wait could act as an Assert.

Upon review I’d consider the test unclear, and I’d have to add a comment saying “no assert because the wait will fail”. Also it would mean a reliance on abstraction layers or Waits, but the system may change over time and the abstractions and necessary Waits may also change. But since I encode the test rationale in the Asserts, if all the Asserts become irrelevant and we remove them, then we also remove the need for the @Test itself.

Also I don’t add asserts to my abstraction layers, but I do add WebDriverWaits.

Semantically they differ, even if the end result of using them might seem the same.

Posted in FAQ | Leave a comment

Question: Which Fitnesse framework should I use with Selenium?

We have a Fitnesse server set up and use Selenium 2 (webdriver). Can you please suggest which framework we should use? Xebium, Selenesse, Fitnium, webtest? or Please suggest any other tool you would recommend.

Thanks for the list of Fitnesse addons.

But, I don’t use them.

The addons provide the ability to encode Web Actions in FitNesse tables. But I don’t do that.

I don’t think that Actions in the FitNesse table lead to maintainable FitNesse documents.

When I work with FitNesse I want to write FitNesse tables at a domain abstraction, not at a physical implementation abstraction. i.e. I want to use it as framework to create a Domain Specific Language, and not use it as a Web Automation Scripting language.

For example:

I do not want to encode tables that look like

| start browser | firefox |
| open url | www.seleniumsimplified.com |
| click on | //a[@id='buy course']|
| verifyTitle | Woo hoo |

I’d rather write tables that look more like:

| A visitor can | buy course | Selenium WebDriver|
| and then | buy book | Java For Testers|

The tables should work at the domain of the test and the reader, not the domain of the application implementation.

By doing the above they become maintainable because the code exists in the IDE and at the language level, rather than in tables in FitNesse.

If the implementation changes, the test still remains valid because it documents the capabilities and requirements and not the implementation.

I view FitNesse, and Cucumber, as a way of creating Domain Specific Languages to write executable specifications, which we can potentially also use for BDD.

I describe this in my BDD tutorial, but I’m not sure how well it comes across in the slides http://www.slideshare.net/eviltester/lessons-learned-with-bdd-a-tutorial

Hope that helps. Thanks for the Question.

Posted in FAQ | 2 Comments

Question: What else do I need to master?

“I have a question: What else do I need to master, besides Selenium and the obvious complementary stuff like HTML, CSS, JavaScript, JQuery?”

A question that opens a whole world of investigation. I guess different people will need to learn different things. So some of the ‘obvious’ complementary stuff first:

Basic Developer ‘stuff’:

  1. Learn your chosen programming language well
  2. Learn the Unit Test framework that you are going to use
  3. Learn the IDE you are going to use
  4. Learn the supporting tools e.g. maven
  5. Learn how to read the error messages of the tools and the programming language
  6. Learn how to use the debug features in your tools

Basic Web Stuff:

  1. As well as HTML and CSS, learn how the DOM hangs together and how to traverse it in the browser using the inbuilt developer tools and plugins like FireBug
  2. As well as JavaScript in general, learn the specific things that will likely make it tricky for you to automate – Ajax, DOM amendment, Event Handling
  3. Still useful to learn XPath for those parts applications that don’t have a good route through the HTML for locator strategies

Learn WebDriver:

  1. Get in the habit of reading the underlying WebDriver code. Especially the ‘Support’ classes as they offer good examples of how to ‘wrap’ or supplement WebDriver

Intermediate Developer ‘stuff’:

  1. Learn refactoring
  2. Learn how to build abstraction layers and various programming patterns
  3. Learn how to Unit test your supporting test code
  4. Learn Domain Driven Design to help you understand how to build domain specific abstraction layers

Intermediate Web ‘stuff’:

  1. Try and keep up to date with Web Development practices, even if it is just through reading news stand magazines on Web Development
  2. Setup your own web server and run apps so you learn how to read and access the server logs
  3. Learn to use Debug proxies so you can see the traffic and investigate the raw HTML as well as the DOM based HTML

Practice.

A lot of the skills I need for WebDriver have come from solving problems and building tests for real applications.

Try and automate applications that use a lot of Ajax, or a lot of 3rd party JavaScript libraries, or have auto generated code like the GWT apps.

Try and use other libraries, not associated with WebDriver, e.g. HTTP libraries, and see if you can use them in combination with WebDriver e.g. login with HTTP directly and move the cookies from the HTTP session into WebDriver, or from WebDriver across to an HTTP session.

Keep learning as much as possible. I can’t predict what you will need to know. But I guarantee that very little of the supporting technology that you can learn will ever turn out to have been something that wasn’t worth learning.

Posted in FAQ | Leave a comment

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>
Posted in Courses | Leave a comment

FAQ: What to do when things go wrong – first things first?

Things might go wrong when you follow online instructions, or tutorials you see on this blog or others. Your setup might not be the same as mine, you might not notice that some of the earlier steps have failed.

When things go wrong, drop down to the command line and make sure that the basics work:

  • mvn -v
  • javac -version

In your project folder make sure that “mvn clean” works without error.

Then try a “mvn compile” and make sure you don’t get any download errors reported.

Many of the recent questions I receive relate to simple maven configuration issues.

I have created 2 new videos, and a hints and tips lecture, which show some troubleshooting steps that you can take if you encounter maven problems.

These are over on the full Selenium WebDriver course, but I have made them free previews so you should be able to watch them even if you haven’t signed up for the full course.

  1. Maven Troubleshooting Hints
  2. Maven Troubleshooting Downloads
  3. Maven Troubleshooting Proxies and Cache issues

Please refer to these first, if you encounter any maven issues.

You can also read the slideshare presentation.

Posted in FAQ | Leave a comment