0

I need to automate as much as possible the recording of Web test scenarios. Selenium IDE or better Katalon plugin for Chrome seem very effective for this. However what's missing in the recording are the assertions. I've so far found no real alternative than to "add them by hand" after the recording is done.

Now I know which parts of my pages contain relevant output text, i.e. are subject to test. For instance based on ID patterns, class names, tag hierarchy etc.

So given that my web app is in a "known good state", I could theoretically grab the text content of the relevant tags during the recording, and insert my assertions in the recorded scenario right there and then. My aim is to automate this.

Is there any way to do this in Katalon plugin, Selenium IDE or any other automated web recording tool? I've read about Katalon Extension Scripts but as far as I understand it, these cannot do what I want?

-- edit -- trying to rephrase and be more concrete --

During my recording, on certain events (e.g. on page load) I want the tool to find all elements that match certain selectors, and for each match store an assertion in the scenario that asserts the actual current value (e.g. div.innerText or input.value) of the element on the page. I want to define the events and the selectors that should trigger the insertion of assertions and the expression that defines the asserted value.

example

Suppose my webapp has a search page. I enter data in input fields, and hit the "search" button. These actions are recorded by most tools like Katalon Recorder. Now on the next page, the search results will show. Each search result will be in a div class="result". Suppose while recording I got two search results "foo" and "bar". So I want the tool to store in the scenario, while recording, an assertion that the first result should be "foo" and the second should be "bar", based on my rule that all $("div.result") should have their "innerText" asserted upon page load.

geert3
  • 7,086
  • 1
  • 33
  • 49

3 Answers3

0

Avoid using Selenium IDE, as compatibility with Firefox has been discontinued since Firefox version 55, you will thus not be able to run your tests on recent versions of Firefox.

When performing actions in the browser, it is relatively easy to record those actions to re-run them again. It is 100% clear what button you just pressed. You can probably do a million different assertions on a page, it would be difficult for any tool to guess which things you would like to assert and then automatically add those assertions so I would be surprised if you would find a tool that would do exactly what you want.

What is keeping you from writing your own automated tests in code from scratch? From my experience, coding your own tests is not that much slower, but once you are used to doing this you will be able to tackle more complex problems with much more ease.

I have no experience with Katalon.

Pieter A
  • 166
  • 3
0

You can't add assertions in recording time, but you can use Selenese after recording too. Check official reference here: https://docs.katalon.com/display/KD/Selenese+%28Selenium+IDE%29+Commands+Reference

plaidshirt
  • 5,189
  • 19
  • 91
  • 181
  • Thanks but this is again post recording. I want some "business user" to use the application while recording, and have the relevant parts automatically asserted. Once the recording is done, the data (text contents of relevant parts) is gone so it's a lot harder to reconstruct the assertion values. – geert3 May 10 '18 at 12:44
  • So you are looking for some solution like Checkpoints in QTP. As I know it is not implemented in Katalon. – plaidshirt May 10 '18 at 14:14
0

For what it's worth, I've managed to get what I needed as follows:

  • locate the Extension directory of Katalon Recorder in my Chrome
  • copy the entire contents to Eclipse
  • modify the source content/recorder.js, method Recorder.attach() by adding the following:

    var self = this;
    $(...).each(function(i, el) {
        var target = self.locatorBuilders.buildAll(el);
        if (el.tagName == "SELECT" || el.tagName == "INPUT")
            recorder.record("assertValue", target, el.value, false);
        else
            recorder.record("assertText", target, el.innerText, false);
    });
    

    (note ... are the JQuery selectors that define the areas that I know will contain relevant data in application. This could be tweaked either in this source (e.g. by adding more selectors), or in the application itself (e.g. by adding a signaling class to certain tags in the HTML just to trigger assertions).

  • in chrome, activate "developer mode" and load the modified plugin.
  • While recording, assertions are now automatically added for the relevant parts (... in the above) of my web app, on each page load.
  • happy!
geert3
  • 7,086
  • 1
  • 33
  • 49