Selenium is a free set of tools for testing web applications in the browser. Information, downloads and a good online documentation is available at http://docs.seleniumhq.org/.
In short, it allows you to write scripts that will be executed within a browser. There is also a nice add-on for Firefox called Selenium IDE, which enables you to record and edit scripts directly in the browser. You can then also execute the scripts with the add-on.
Why This Blog Series?
I tried to use Selenium IDE for our WDA application and did everything in this blog with the Selenium IDE. Later on, I will also try the “real thing” with the Selenium server (called Web Driver) but first I want to do further tests with the IDE. I would also like to try the SeleniumABAP project by Gregor Wolf, see Automate Web Application Testing with Selenium for ABAP.
I started from zero and wanted to share my learnings here. Using Selenium for “normal” web applications is of course not new and you will find plenty of information about it with your favorite search engine. WDA, however, has some specialties that make browser scripting tricky:
- The ID attributes in the HTML code are not stable. That is quite unusual and makes scripting tricky. I will go into more details in the next part. There are some
So this blog series is about the question: How do I write test scripts with Selenium for WDA?
Why Selenium At All?
Good question 😉 The typical choice for WDA test automation is of course ECATT. Period. There are three reasons why I started looking into Selenium at all:
- The systems you work with may not have eCATT enabled. That is (at least for now) the case for us. Since we are using agile development with short iterations and regular releases, however, we urgently need test automation. So we started looking for options.
- With a tool like Selenium, it seems easier to cover mixed scenarios, where not everything is Web Dynpro.
- Selenium can be used as a client-side tool – so it seems generally easier to start with.
As always, it does not solve every problem – I see it as an additional tool in the box.
Update: August 21
Recently, a colleague of mine (thanks Reik!) pointed me to the URL parameter
sap-wd-stableids=X. It is also mentioned in blogs like Load Testing Web Dynpro ABAP Applications Using Apache JMeter. Apparently, I did not look for such a parameter well enough before.
The parameter causes WDA to generate stable IDs in the HTML code. That makes much of what you see in part 2 and 3 a lot simpler! I can think of only three reasons why everything I wrote in those two parts may still be of interest:
- The parameter may not work in all scenarios. For example, it does not work on our landing page. We are still trying to find out why.
- Not everything on the page gets an ID. So for some text validations, you may still need some advanced XPath sytax.
- When scripting navigation steps within your application, that parameter will not be passed on automatically. Selenium does not simulate http requests, where you could manually add the parameter. I could think of ways to handle it with Selenium, where I save parameters in the source screen and then call the target screen with a new “open” command. But I simply have not played with that yet and cannot share any experience. So if you want to script navigation, the parameter may not solve all problems with IDs.
In part 2, I will start describing how I wrote our scripts in detail. Part 3 adds some advanced things. (At least advanced for me…)