Hi,
avoid ifStep when possible, create custom clickLink that accepts label
or href with your logic to distinguish them.
What about
assert ("${Label}".indexOf("/html") != -1);
rather than
assert (${Label}.indexOf("/html") != -1);
Cheers,
Marc.
--
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com
Kelcy Monday wrote:
> I forgot to attach the spreadsheet:
>
>
>
> _________________________________________________________________________
>
>
> This example test will always fail with the exception: 2/2 executions of
> nested tasks failed:
>
> <webtest name="try data driven">
> &sharedConfig;
> <dataDriven tableContainer="test.xls">
> <invoke url="${Page}" />
> <enableJavaScript description="Disable JavaScript"
> enable="false" />
> <!-- If label is in the form of an xpath,
> clickLink with xpath, if not, then
> clickLink with label -->
> <ifStep>
> <condition>
> <groovy description="Check to see if the label is really an
> xpath"
> replaceProperties="true" >
> assert (${Label}.indexOf("/html") != -1);
> </groovy>
> </condition>
> <then>
> <clickLink xpath="${Label}" />
> </then>
> <else>
> <clickLink label="${Label}" />
> </else>
> </ifStep>
> </dataDriven>
> </webtest>
>
> This test reads in data from a given spreadsheet (attached). The first
> column is a list of relative URLs. The second column is a list of href
> links on corresponding URL. The third column is the label associated
> with the href link.
>
> Some of the "labels," however, are listed as xpaths (starting with
> /html/body...) I need to be able to distinguish when a label is in
> xpath form, so I chose to make a groovy assertion based on the java
> indexOf() method. For some reason, though, webtest always fails on this
> assertion. I have also tried evaluating the string with an if/else
> block. This failed with similar results. I also tried storing the ant
> variable as a webtest property and evaluating it this way. This also
> failed.
>
> Note: I have tried echo-ing the ${Label} variable inside the groovy
> block and it represents the string correctly.
>
> Table Data:
> _Column 1_
> Page
> /cgi-bin/dynamic/topbar.html
> /cgi-bin/dynamic/printer/langbar.html
>
> _Column 2_
> Link
> /cgi-bin/dynamic/topbar.html
> /
>
> _Column 3_
> Label
> Refresh
> /html/body/table/tbody/tr/td/form/a[0]/img
>
> Using WebTest at R_1758
>
> Thanks,
> Kelcy Monday
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest