Last time, I did a quick run-through of Selenium IDE for Firefox and got acquainted with the interface and commands associated with Selenium. This time, I’m diving more into the meat of the framework and using Webdriver.
Webdriver is an API for that can be used by various languages (C#, Java, Python, & Ruby are some examples) that allows your tests to be maintained and run directly from code rather than using a recorder. This allows us to take a more programmatical approach to testing rather than relying on the recorder exclusively.
We will be using Visual Studio for this example. Firefox is supported right out of the box, but IE and Chrome require a special binary to be staged locally in order for those browsers to be used with Selenium. This (and others) can be located via links at SeleniumHQ.
Since Chrome is my own preferred browser, I’m glad to move away from Firefox and experiment with something a bit more familiar. I decided to start with rerunning the test that I created using Selenium IDE previously, then build on that a bit.
One feature that I didn’t mention about Selenium IDE, is the export function. This creates source code in your chosen framework (C#, Java, etc.) from the Selenium markup code created by the recorder.
One cool thing about the export is that it intersperses the markup within your code as comments. This can be very useful when retracing what was done in a recording or for general documentation.
First off, I created a C# console project and installed the Selenium Webdriver plugin from NuGet. With that in place, I’ve added the export from my previous post to a new project to test with Chrome. My code is below:
This sample using the export from my previous post results in a successful login. Now to build on it a little bit and create a test Incident:
Just adding these few extra lines results in a repeatable New Incident test.
It’s easy to start to see how this framework can be used to build a library of repeatable tests to automate QA and regression testing.
Link to the Full .NET API : http://seleniumhq.github.io/selenium/docs/api/dotnet/
As I continue to progress through the Pluralsight course, my next post should cover advanced WebDriver concepts and possibly Selenium Server.
As always, if you have any questions or comments, please feel free to add them here or address them to email@example.com.
Thanks for looking in!