Our first wrapper just executed a fixed navigation. Next we will do something more interesting: a wrapper that receives input parameters and executes sequences that depend on them.
For example, let's go to this website http://nhqrnet.ahrq.gov/inhqrdr/state/select that contains several healthcare statistics about each state. We are first presented a page that allows us to select a state from a list. We will create a new wrapper that receives a state name as a parameter and accesses the statistics of that state:
Create a new wrapper named "healthcareus".
Double-click the Init component to open the input parameters configuration. Click on the "+" icon to add a new parameter, and let's rename it to "state". Leave the type as "string", check the "Mandatory" checkbox and click "Ok".
Now our wrapper has an input parameter that we can use within the rest of the wrapper. The output of the Init component is a record with a field named "state".
You can see this by clicking on the
Catalog explorer button at the bottom of the workspace; this screen shows all the variables that are present in our wrapper,
categorized by data type. Under the "Records" node you can see an item "Start_1_output"; expand it and you can inspect the structure of the record, it has one "state"
field of type string.
Let's add a new Sequence component to carry out the access to the specific state page. Link the Start component to it as we did before.
As the input US state is needed for executing the navigation, let's pass this variable to the Sequence component. Click on the Sequence component and click the "+" symbol on the right of the "Input values" input field of the component. This will enable the selector, and on it select the "Start_1_output" value. this will make the fields of the output record of the init component available to use within the sequence that we record.
Now, let's record the navigation sequence. Open a new browser from the
Browser > New browser menu.
Rec button and select http://nhqrnet.ahrq.gov/inhqrdr/state/select as the initial URL.
Now, we must select the state that the user specified as our input parameter. Right-click on the "Select a state" selector and click on
Select option. This will show a
dialog where you can select a state.
Select "California", for example. But now, we will specify that at runtime ITPilot should use the value of the input variable instead of hardwiring "California", so we type "state" (which was the name of our parameter in the init component) in the "Variable name" of the dialog. Click "Ok".
The browser will select "California" in the selector, so right-click over the "Go" button and select
Finally, in our navigation process we will go to the full table of results so we can extract the data and return it as a result. Right-click on the "Review underlying data"
link and select
After we reach the results page click
Stop, back in the Sequence component wizard in the WGT click
Import from browser, and click "Ok".
If we test our wrapper right now, when you click the
Test wrapper button you will see the first dialog will show a "State" input parameter that we need to
specify before executing the wrapper. Type "Indiana" and click
Execute wrapper. You will see a browser window appearing and performing the navigation that we specified
when recording the sequence, but this time it will select a different state (Indiana instead of California).
To complete the wrapper, let's apply the lessons learned in our previous wrapper and extract the data from the table in the underlying page.
Add an Extractor component and set the "Sequence_1_output" value as the input page of the component.
In the browser, select the
Assign Examples button and add a two examples with four fields:
|measure||Short-stay nursing home residents with delirium|
|distance||Achieved: 28 % better|
|measure||Central line-associated bloodstream infection per 1,000 central line-days in all intensive care units|
You can see that the first example contains values for all fields, but the second example contains only values for the measure and estimate fields. This way ITPilot will learn that there is two types of records to extract and it will retrieve all of them from the page.
In the Extractor component wizard click the
Import from browser button at the top left and test the component in the "Specification test" panel.
Set up the Output component to return the data extracted by the Extractor component, as we did in the previous wrapper.
Test the wrapper and verify that it extracts the intended measures from the table of data for the state name that you pass as a parameter.
We have created a parametrized wrapper, that will execute different things depending on the values of the parameters that we pass to the wrapper. Let's move to new examples that show other common patterns in pages.