Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Suppressing errors on dynamic url

Options
LegacyForum
LegacyForum Posts: 1,664 ✭✭
I have an errors I want to suppress on a url that has a constantly changing value
e.g. ...examplePage.do?id=20456
In the above example id is incrementing everytime therefore Webking thinks it's a different page everytime. So when I supress the error it only supress's for the page with id=20456, so the next time I run the test suite and the page is ...examplePage.do?id=20457 Webking will fail that test and alert me of the error I want to supress, again! How do I edit a suppressions url so it's just examplePage.do? And will this suppress errors from pages with different ids?

Just in case your wondering the error I want to suppress is a javascript error in which a var could be undefined when referenced. The chance is extremely unlikely and this potential bug is far from being on the priority fix list of our developers.

Thanks

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    In order to ignore errors on pages with dynamic urls do the following:

    On the test with relevant error create a new method tool output by right clicking then choosing: Add Messages Output -> New Output -> Method
    For the method tool function choose JavaScript and paste the following into the text field:

    function ignoreErrors(messages, methodToolContext) {
    Packages.com.parasoft.app.App.showMessage("Got here");
    var errors = messages.getErrorCollection();
    for (var i = 0; i < errors.size(); i++) {
    var error = errors.get(i);
    // MODIFY THIS IF BLOCK TO MATCH THE IGNORE CRITERIA YOU WANT
    if (error.toString().indexOf("mispeled") > -1) {
    errors.remove(error);
    i--;
    }
    }
    return outputLikeNormalErrors(errors);
    }

    function outputLikeNormalErrors(errors) {
    var output = "";
    var it = errors.iterator();
    while (it.hasNext()) {
    output += it.next().toString() + "\n";
    }
    return output;
    }

    Make sure the drop down box entitled "Method" is set to ignoreErrors()
    On the method tool right click and choose: Add Return Value Output -> New Output -> Diff Tool
    Then simply right click the test and choose Update Reqression Control.