About Selenium

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:

  1. Almost everything is AJAX. The page is not reloaded when you click somewhere; instead, new page content is loaded from the server with JavaScript. That, of course, is also not unusal in normal web applications. The bigger problem is:
  2. 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:

  1. 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.
  2. With a tool like Selenium, it seems easier to cover mixed scenarios, where not everything is Web Dynpro.
  3. 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:

  1. 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.
  2. Not everything on the page gets an ID. So for some text validations, you may still need some advanced XPath sytax.
  3. 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.


Next?

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…)

Test Scripts for WDA with Selenium – Part 2: Writing The First Two Scripts

Test Scripts for WDA with Selenium – Part 3: More Advance Stuff With XPath

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply