Hi Colin,
I use steps like
<click xpath="//tr[#{count}+1]//a" .../>
in my webtests therefore I guess that your xpath is syntactically
correct. Have you tried to test it on the page code in XPE or in an
other xpath tool?
Marc.
Colin O'Brien wrote:
Hi Marc et al,
Can you confirm if either of the following xpath syntax is supported in
webtest...
xpath="//[EMAIL PROTECTED]'add_w1_sel']/option[n + 1]"
or
xpath="//[EMAIL PROTECTED]'add_w1_sel']/option[sum(n + 1)]"
where 'n' is an integer
What I'm trying to achieve is count the number of options in a dropdown
list, select each option in turn and click an associated 'Add' button.
XPath Explorer handles both without a problem
Webtest Steps:
<steps>
&Login;
&JS_on;
&LogToHome;
<storeXPath
description="Count the number of portlet options"
xpath="count(//[EMAIL PROTECTED]'add_w1_sel']/option)"
property="portletCount"
/>
<repeat description="Add all avaialble portlets"
count="#{portletCount}">
<storeXPath
description="Store portlet name"
xpath="//[EMAIL PROTECTED]'add_w1_sel']/option[#{count}
+ 1]"
property="portletName"
/>
<setSelectField
description="Select Portlet:#{portletName} from
dropdown list"
name="add_w1_sel"
optionIndex="#{count}"
/>
<clickButton
description="Click add to insert
Portlet:#{portletName} to dashboard"
label="Add"
/>
</repeat>
</steps
HTML:
<select name="add_w1_sel" class="layout-add-select-style">
<option value=""></option>
<option value="74">Breadcrumb</option>
<option value="11">Directory</option>
<option value="20">Document Library</option>
<option value="31">Image Gallery</option>
<option value="15">Journal</option>
<option value="63">Journal Articles</option>
<option value="57">Journal Content</option>
<option value="2">My Account</option>
<option value="72">Navigation</option>
<option value="76">Portlet Aggregator</option>
<option value="alarms_WAR_ro_portlets">RO Alarms</option>
<option value="datasource_viewer_WAR_ro_portlets">RO Data Source
Summary</option>
<option value="fileaudit_viewer_WAR_ro_portlets">RO File Audit
Viewer</option>
<option value="kpilist_WAR_ro_portlets">RO KPI Portlet</option>
<option value="volumeprofilechart_WAR_ro_portlets">RO Profile Chart</option>
<option value="reconchart_WAR_ro_portlets">RO Reconciliation Chart</option>
<option value="revenuestreamchart_WAR_ro_portlets">RO Revenuestream
Chart</option>
<option value="status_WAR_ro_portlets">RO System Status</option>
<option value="66">Web Proxy</option>
</select>
Webtest reports the following errors:
********************
[testSpec] INFO (com.canoo.webtest.steps.Step) - Message was: No match for
xpath expression <//[EMAIL PROTECTED]'add_w1_sel']/option[0 + 1]>
********************
********************
[testSpec] INFO (com.canoo.webtest.steps.Step) - Exception thrown from
this cl
ass: org.jaxen.FunctionCallException
[testSpec] INFO (com.canoo.webtest.steps.Step) - Message was: The argument
to
the sum function must be a node-set
[testSpec] ERROR (com.canoo.webtest.steps.Step) - Cannot handle unexpected
exce
ption in step StoreXPath at D:\canoo\UseCases\ROCDR_TC1721_v4.0.xml:41:
with (p
roperty="portletName", description="Store portlet name",
xpath="//[EMAIL PROTECTED]'
add_w1_sel']/option[sum(0 + 1)]", stepType="storeXPath")
[testSpec] org.jaxen.FunctionCallException: The argument to the sum
function mu
st be a node-set
[testSpec] at
org.jaxen.FunctionCallException.fillInStackTrace(FunctionCall
Exception.java:124)
[testSpec] at java.lang.Throwable.<init>(Throwable.java:195)
[testSpec] at java.lang.Exception.<init>(Exception.java:41)
[testSpec] at
org.jaxen.saxpath.SAXPathException.<init>(SAXPathException.ja
va:83)
[testSpec] at org.jaxen.JaxenException.<init>(JaxenException.java:82)
[testSpec] at
org.jaxen.FunctionCallException.<init>(FunctionCallException.
java:82)
[testSpec] at
org.jaxen.function.SumFunction.evaluate(SumFunction.java:114)
[testSpec] at org.jaxen.function.SumFunction.call(SumFunction.java:87)
[testSpec] at
org.jaxen.expr.DefaultFunctionCallExpr.evaluate(DefaultFuncti
onCallExpr.java:182)
[testSpec] at
org.jaxen.expr.DefaultPredicate.evaluate(DefaultPredicate.jav
a:105)
[testSpec] at
org.jaxen.expr.PredicateSet.applyPredicate(PredicateSet.java:
176)
[testSpec] at
org.jaxen.expr.PredicateSet.evaluatePredicates(PredicateSet.j
ava:151)
[testSpec] at
org.jaxen.expr.DefaultNameStep.evaluate(DefaultNameStep.java:
220)
[testSpec] at
org.jaxen.expr.DefaultLocationPath.evaluate(DefaultLocationPa
th.java:151)
[testSpec] at
org.jaxen.expr.DefaultAbsoluteLocationPath.evaluate(DefaultAb
soluteLocationPath.java:117)
[testSpec] at
org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:
108)
[testSpec] at
org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:692)
[testSpec] at
org.jaxen.BaseXPath.selectSingleNodeForContext(BaseXPath.java
:714)
[testSpec] at org.jaxen.BaseXPath.stringValueOf(BaseXPath.java:287)
********************
Kind Regards,
Colin.
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest