Since the Selenium API has been deprecated by the main WebDriver project, although it can still be found in the current versions of Selenium WebDriver, I have moved the example to a separate github project.
Selenium Simplified targets the Selenium 1.0 API. This has not changed in Selenium 2.0
Selenium 2.0 bundles together the Selenium 1.0 server and API and the WebDriver code base.
I recently checked how compatible Selenium Simplified was with Selenium 2.0.0 and was pleasantly surprised.
This blog post describes how to follow the Selenium Simplified book using Selenium 2.0.0 and what you might expect to have happen.
Oh, and it works really well. You don’t have to change very much at all. Once you understand what to download, and how to use the correct jar versions in your build path and ant files, you will be fine.
I’ve structured this blog post so that it maps on to the structure of the book.
Create HTML suites from IDE
The Selenium IDE lets you create HTML suites and save them to html files so we don’t need to create these by hand any more.
Simply add the tests to the side of the ide and save as html.
Then you can run them with -htmlunit as described in the text.
-htmlunit works now
On page 24 there is a big warning saying do not use the -htmlunit to run selenese test suites.
Well this seems to work in Selenium 2 .0.0
I don’t recommend it as a good approach as I think you should move to coding your tests, but if you want to then you should be able to do this in Selenium 2.0.0 much more consistently than in 1.0.3
the 1.0.3 build (in the Selenium Client Drivers list (listed in the table as a C# (Selenium RC)). This is the version that the book was written against.
the 2.0.0 Standalone Server and the Java 2.0.0 Client Driver (you need to download both if you want to follow through with the Selenium Simplified book, the Client Driver has the source code .jar and the standalone server has everything else)
Since everything works with Selenium 2.0.0 and Selenium 2.0.0 handles the most up to date versions of the browsers you are using, you should probably use this.
If you want to use Selenium 2.0.0 then the jars you need to add to your build paths and ant files is:
I ran through all the tests and all I did was change the jars that the project used. I used the 2.0.0 jar instead of 1.0.3 jars
SeleneseTestCase has been deprecated
SeleneseTestCase has been deprecated in Selenium 2.0 so you will see it scored through when you work with it using the Selenium 2 jars. This isn’t a problem as Selenium Simplified moves you away from this very quickly.
SaveAs from the IDE instead of view code
On page 38, in previous versions of the IDE you could view source in different languages. Now the view source is always html. You have to saveAs the test case in different formats. So saveAs the test case into Junit4 format.
Page 57 starts to describe the process of attaching the selenium source code.
The source-code is contained in the Java Client download as selenium-java-2.0.0-srcs.jar, so attach this to your Java project to see the Selenium source-code in the IDE.
Firefox and IE don’t work!
If you are using Selenium 1.0.3 then Firefox 4 probably doesn’t work. I was using Firefox 3.0 and 3.5 with the book
The getEval does work. If you use “window.document.getElementById(‘combo1’).innerHTML;” This still demonstrates the intent of the test.
If you want to use assignId on firefox then you might have to use getEval to ‘simulate it’ e.g.
String result = selenium.getEval(“window.document.forms.setAttribute(‘id’,’form1′);”);
To achieve the same effect.
Pretty much everything worked. This shows that the Selenium team have done a really good job of backwards compatibility.
I suspect that some of the above issues will be resolved by future updates to the drivers.
Once you are past the initial setup sections of the text. You should have no real problems. Unfortunately the initial setup sections is when you need most help, so if you can’t follow the instructions here then email me and I’ll try to help.