Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
retrieving values of fields from a web page
#1
Not Solved
Hi,
I am using QTP 11, Internet Explorer 7 and 8.
my Application has a web page that displays a table containing fields' names and their values.
I want to retrieve values of particular fields from this page.
I am facing a problem while retrieving these values because, depending on the user rights, a field can be displayed either as a WebEdit (user can edit the field's content)
or a WebElement (field is read only).
The same fields can be read only for one user, and editable for the other, and I cannot predict how the field will be displayed.

Below is an example how HTML code of this page looks like,
this code contains two fields: FieldName1 & FieldName2 with corresponding values: Value 1 and Value 2.
FieldName1 is editable, and FieldName2 is read only.
Code:
<table>
<tr>
    <td width="16" class="wcmFormRowEven">&nbsp;</td>
    <td nowrap="true" width="170" scope="row" class="wcmFormRowEven">FieldName1:</td>
    <td width="100%" class="wcmFormRowEven"><input size="42" type="text" title="Właściwość:FieldName1, Typ: ciąg" class="wcmFormText" maxlength="64" value="Value 1" name="FieldName1"></td>
</tr>
<tr>
    <td width="16" class="wcmFormRowEven">&nbsp;</td>
    <td nowrap="true" width="170" scope="row" class="wcmFormRowEven">FieldName2:</td>
    <td width="100%" class="wcmFormRowEven">Value 2<input disabled="true" value="Value 2" name="FieldName2" type="hidden"></td>
</tr>
</table>
I created two simple pages to illustrate the problem and to play with it:
http://mtvk.pl/kordirko/xx1.html
http://mtvk.pl/kordirko/xx2.html

Currently I use the below code to retrieve values from this page:
Code:
If Browser("Test page").Page("Test page").WebEdit("html tag:=INPUT", "class:=wcmFormText", "name:=FieldName1" ).Exist Then
      strValue = Browser("Test page").Page("Test page").WebEdit("html tag:=INPUT", "class:=wcmFormText", "name:=FieldName1" ).GetROProperty("default value")
ElseIf  Browser("Test page").Page("Test page").WebElement( "class:=wcmFormRowEven", "html tag:=TD", "innerhtml:=.*<INPUT disabled name=FieldName1 value=.*type=hidden>" ).Exist Then
     strValue = Browser("Test page").Page("Test page").WebElement( "class:=wcmFormRowEven", "html tag:=TD", "innerhtml:=.*<INPUT disabled name=FieldName1 value=.*type=hidden>" ).GetROProperty( "outertext" )
Else
    strValue = "ERROR!!!"
End if

MsgBox( strValue )
This code works fine, it tests if a WebEdit object exists on the page, if yes --> retrieve the value from the WebEdit, if not exists --> from the WebElement.
The problem is that I have to check hundreds of fields from many pages, 50% of fields are read only on avarage,
and the test for existence of fields takes ages.
How can I improve this code, is there any smarter way to manage this case? Please advice.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  click each web link in a page using Index or other method in QTP smeijer 13 24,819 04-29-2017, 04:53 PM
Last Post: kowshik
  VB Script to count number of links in a web page. Suma Parimal 4 25,376 07-01-2015, 12:59 PM
Last Post: govind
  How to check empty fields? ripchin 1 3,444 05-10-2014, 01:18 PM
Last Post: Ankur
  How to mask the particular read only mode fields while capturing screenshot in QTP kalaivanan123 2 3,580 03-18-2014, 11:31 AM
Last Post: basanth27
  Retrieving data from web table nsuresh316 1 3,159 03-03-2014, 08:29 AM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 1 Guest(s)