[Webtest] How to Get value from a field

Marc Guillemot webtest@lists.canoo.com
Mon, 02 Feb 2004 13:28:15 +0100


Siju John wrote:
> We have "setinputfield" to set the value to a given field.
> I want the opposite. I want to get the value of the given field.
>  
> e.g. unique id = 1
> I want to get the value "1" provided the unique id name.
> Pls anybody can help.

With xpath you can read all what you want, eg for

<input type="text" name="foo" value="1">

you can use

<storexpath xpath="//input[@name='foo']/@value" property="myProp"/>


If you have more than one field named "foo" in the page, the best way is to add 
an id:

<input type="text" name="foo" id="theFieldIWantToRead" value="1">

then you can use

<storexpath xpath="//input[@id='theFieldIWantToRead']/@value" property="myProp"/>

Hope this helps.

Marc.