xpath help

6 views
Skip to first unread message

b1alpha

unread,
Jun 5, 2007, 12:50:19 PM6/5/07
to watij
Resources: http://www.w3.org/TR/1999/REC-xpath-19991116#section-String-Functions
http://www.stylusstudio.com/docs/v60/d_xpath39.html

I am trying to figure out how to select with Xpath something that ends
with 'MWI'

I am getting a null pointer error when I use this. Does anyone have
examples of some working string compare xpaths?

<watij-set-select-list
functionId="Set the 'MWI' option of a select field"
how="xpath"
what="string contains(//SELECT[@name],MWI)"
/>

Christian Hargraves

unread,
Jun 5, 2007, 1:14:00 PM6/5/07
to wa...@googlegroups.com
try:

<watij-set-select-list
functionId="Set the 'MWI' option of a select field"
how="xpath"

what="//SELECT[contains(@name, 'MWI')]"
/>

b1alpha

unread,
Jun 5, 2007, 1:49:03 PM6/5/07
to watij
Ok thank you, I see how the syntax works, my HTML actually looks like
this;

<select name="server_name" size="10" style="width: 300px;">
<option value='10022' selected>
pstn3 - MWI

.../>

So I want to select the name elements childs char data? Is there
something for that?

thanks again,

./b

b1alpha

unread,
Jun 5, 2007, 2:40:45 PM6/5/07
to watij
I have tried a number of things.

For example;

<watij-set-select-list
functionId="Set the 'MWI' option of a select field"
how="xpath"

what="SELECT//OPTION[contains(text, 'MWI')]"
/>

Still re-reading the xpath tutorial: http://www.w3schools.com/xpath/xpath_syntax.asp

Any further help would be greatly appreciated.

On Jun 5, 10:14 am, "Christian Hargraves" <engr...@gmail.com> wrote:

b1alpha

unread,
Jun 5, 2007, 7:33:27 PM6/5/07
to watij
Ok I am having trouble getting anything to work today.

Not only can I not select this item from a select list, im having
trouble clicking a button. There is a null pointer error here too.

watij
ie().button(getSymbolFromString(how),what).click();

html
<input type="submit" name="apply" value="&nbsp; run &nbsp;"
class="buttonLabel">


error
java.lang.NullPointerException
at
net.sf.jameleon.plugin.watij.WatijFunctionTag.store(WatijFunctionTag.java:
103)
at
net.sf.jameleon.util.StateStorer.storeState(StateStorer.java:205)
at
net.sf.jameleon.util.StateStorer.eventOccured(StateStorer.java:129)
at net.sf.jameleon.function.FunctionTag.doTag(FunctionTag.java:
292)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:
262)
at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at net.sf.jameleon.SessionTag.doTag(SessionTag.java:191)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:
262)
at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at net.sf.jameleon.TestCaseTag.invokeChildren(TestCaseTag.java:
643)
at net.sf.jameleon.TestCaseTag$1.run(TestCaseTag.java:843)
at net.sf.jameleon.TestCaseTag.executeBody(TestCaseTag.java:
896)
at net.sf.jameleon.TestCaseTag.executeNoCSV(TestCaseTag.java:
841)
at net.sf.jameleon.TestCaseTag.doTag(TestCaseTag.java:789)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:
262)
at
org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:706)
at
org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:670)
at
org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:579)
at
net.sf.jameleon.ExecuteTestCase.runScript(ExecuteTestCase.java:302)
at net.sf.jameleon.ui.TestCasePane$ExecuteButtonAction
$2.run(TestCasePane.java:293)


On Jun 5, 10:14 am, "Christian Hargraves" <engr...@gmail.com> wrote:

b1alpha

unread,
Jun 5, 2007, 7:34:10 PM6/5/07
to watij
how="name"
what="apply"

On Jun 5, 10:14 am, "Christian Hargraves" <engr...@gmail.com> wrote:

Christian

unread,
Jun 5, 2007, 7:49:10 PM6/5/07
to watij
I see two problems:

1) you aren't telling it what to set. Take a look at the acceptance
tests in watij-plugin/tst/xml/acceptance/watij-set-select-list-
success.xml
2) I don't see any reason for using XPath in this situation. You know
the field name so use:

<watij-set-select-list
functionId="Set the 'MWI' option of a select field"

how="name"
what="server_name"
select="pstn3 - MWI"
/>

or

<watij-set-select-list
functionId="Set the 'MWI' option of a select field"

how="name"
what="server_name"
selectValue="10022"
/>

Christian

unread,
Jun 5, 2007, 7:49:58 PM6/5/07
to watij
This would probably be more appropriate to post these to the Jameleon
forums instead of this one.

Christian

unread,
Jun 5, 2007, 7:51:33 PM6/5/07
to watij
Your problem is that you are using the getSymbolFromString method, but
you are passing in the actual Symbol.

Try:

ie().button(how,what).click();

On Jun 5, 7:33 pm, b1alpha <b.1.al...@gmail.com> wrote:

b1alpha

unread,
Jun 5, 2007, 7:52:55 PM6/5/07
to watij
Yea, thanks. It was a namespace prefix missing so I wont bother
posting it. both problems were.

./b

webwicht

unread,
Jun 6, 2007, 3:26:32 AM6/6/07
to watij
following XPath expression will work:

what="//SELECT/OPTION[contains(text(), 'MWI')]"

Reply all
Reply to author
Forward
0 new messages