[TestOptimal] Write mScript

TestOptimal   Wiki Home   Support  

To write mScript, you will need an XML editor. Notepad would work too if you don't have an XML editor.

First have TestOptimal generate the skeleton mScript code for you from the model you've just built. To do so, just click on mScriptTab, the mScript displayed is the mScript we will use. Right-mouse click on the script content and select "View Source" option, copy and paste the code into your XML editor.

The skeleton code should look like this.

Now you are ready to plug in testing script to tell TestOptimal how to interact with the web pages. We will use the ProductList state to demonstrate how to write the script for all of its transitions.

There are 4 transitions in ProductList, so we have 4 scripts to write.

If you look at the skeleton script, you might have noticed that there are 2 sets of function stubs under each state and 3 sets of function stubs under each transition. For this tutorial, we will not use any of the state functions, but we will use one of the transition function action.

Since all transitions under ProductList are clicking on the links, we have a one line to write for each of the transition for ProductList state:

  <action code="click(element_locator)"/>

"element_locator" is a string to locate the link on the page. There are several ways to specify the locator.

All of the links except addItem has an id assigned, so we will use the id locator for those transitions and use name locator for addItem link.

Add the code above to the script function for each of the transition and your xml code should look like http://TestOptimal.com/img/WebStoreProductScript.jpg.

Continue with the remaining 4 other states. The completed mScript should look like this. If you want, you can just use view source option to get this code and paste to your XML editor.

Finally you need to deploy the mScript you've just created. To do so, copy or save to the /script/ folder under TestOptimal home directory using the same name as the model name "MyWebStore.xml" except it has ".xml" as the extension.


Page locked (last edited April 26, 2009) [info] [diff])
FindPage by browsing or searching
5 best incoming links: WebStore (6)
5 best outgoing links: mScriptTab (13), mScriptTags (11), ProductList (5)
5 most popular nearby: mScriptTab (526), mScriptTags (525), WebStore (511), ProductList (256)