PDA

View Full Version : Reading text field values generated by extJS4



suryanarendra
1 Jun 2012, 12:41 PM
I am using ExtJS4 to develop my UI.

I am using read only form and loading it in the controller using

"popup.down('form').loadRecord(record);"


Form fields are defined as

items:[
{
xtype:'textfield',
fieldLabel:'Array Id',
name:'id'
},
{
xtype:'textfield',
fieldLabel:'Array Name',
name:'name'
}
]

values : [ id:10, name: 'testing']

Now the issue is I want to read the id (value: 10) and name (value: testing) values form generated HTML.

The generated HTML code is:
<form id = 'arraydevicewindowid'>

<input type="text" autocomplete="off" class="x-form-field x-form-text" size="20" name="${array.arrayName}" id="ext-gen1314" readonly="" aria-readonly="true" aria-invalid="false" placeholder="--NA--" role="textbox" aria-describedby="textfield-1260-errorEl" aria-required="false" data-errorqtip="" style="width: 281px; height: 23px;">

</form>

I tried to use the following xpath to select value from a textfield component generated by Extjs:
(//div[@id='arraydevicewindowid']//input)[1]//@value

but it is returning null.

The values don't exist in HTML form but is there any way I can read the values by setting some properties inside form.

Thanks and Regards,
Nari

Tim Toady
1 Jun 2012, 12:57 PM
Why do you want to read their values from html when you can just do popup.down('form').getValues()?

suryanarendra
1 Jun 2012, 1:17 PM
I want to read those values on Client Side for testing purpose

Tim Toady
1 Jun 2012, 1:29 PM
Client side? Your JS will be client side. Can you expound?

suryanarendra
1 Jun 2012, 1:33 PM
I am using selenium to test my UI screens. To read values in selenium i am using xpaths. As values are not appearing on HTML my tests are getting failed.

scottmartin
1 Jun 2012, 1:51 PM
I thought Selenium required the id of the component for it to work correctly?

Scott.

suryanarendra
1 Jun 2012, 1:58 PM
It's not the case always. As extJS4 randomly generating ids for components we are using xpaths, instead to select components. Even selection through ids is going to use xpaths internally.