Browser History Navigation

Last edited on

Overview

Squish is able to navigate through the browser history as if the user would have clicked the browser buttons Back or Forward.

While those buttons are not part of the web application's DOM tree, it might be possible to simply record clicks on those buttons depending on the Squish editions that are covered by the license and the specific Browser (e.g. with a Squish for Web+Windows license and using Microsoft Internet Explorer). On the other hand, this is not the recommended approach, as it won't work for pure Squish for Web license holders and creates a test script that depends on the browser.

To avoid this and to create a cross-browser script, one can access the JavaScript history object through the window object that displays the DOM tree of the web application. To access the browser's JavaScript interpreter, Squish provides a function called evalJS(code); .

To load the previous URL, simply add the following statement to your test script:

evalJS("window.history.back();")

To navigate forward, execute this statement:

evalJS("window.history.forward();")

Or use the method history.go(number) to load another URL back in the timeline:

evalJS("window.history.go(-2);")