javawebtestcanoo

How to replace a URL in a canoo webtest


I have a canoo webtest where I would like to replace the current document URL by a new one, and proceed to that URL. Specifically, I'd like to replace a string "view.html" in the current document URL by "view-old.html" and navigate to the new URL.

The script would look like:

<clickButton htmlId="newDocForm_add"/>
<!-- get the url of the newly loaded page and replace "view" with "view-old" -->
< ??? >
<invoke description="go to modified URL" url="...newUrl..."/>

Solution

  • I fianlly ended up doing it differently, by generating the modified URL from an ID field that can be found in the original URL, something like:

      <sequential>
        <ifStep description="if in new document edit, go to old version">
          <condition description="in new doc edit">
            <verifyDocumentURL text=".*/doc/view.html.*" regex="true" description="new doc edit url" />
          </condition>
          <then>
            <storeXPath description="Extract transaction id"
                        xpath="//form[@id='docdata-form']/input[@name='transaction.id']/@value"
                        property="transid" />
            <invoke description="Go to old edit page" url="/doc/view-old.html?id=#{transid}" />
          </then>
        </ifStep>
      </sequential>