0
votes

I have a piece of code in using QTP for a webpage

Browser("Sarit_2").Page("Sarit").WebEdit("frm_vendor_address1").Set dtVAdd1

You will observe, I used a 'Set' property. In reality, I wanted to use a 'Type' property because soon I will write script to check field limit and .Set property throws an error when I try to set a value larger than the field length. But Type property(I used it in win32 app), it types as much as the field length but at least doesn't throw an error I can't handle.

QTP in WebEdit or this particular WebEdit does not allow me to choose .Type. How come it allowed me in the case of SWFfield?

Any suggestions?

4

4 Answers

1
votes

"Type" is a method used for Windows application, Delphi, Java, swf etc... But it is not used for Web application.

For web application we have to use "Set" method. Therefore above piece of code accepts 'Set' method. This also tells why you can not use 'Type' method with web based object.

If you want to count the field limit, you can object spy on the webedit-> save its max length value to any variable-> at run time store max length of that web edit field to variable2 using 'Browser("...").Page("..."). .... .GetROProperty("max length"). Now compare the two variable with if statement.

0
votes

The WebEdit test object is helpfully trying to prevent you from setting an invalid value into the edit field.

You obviously don't want this help the question I'm not clear on is what you're trying to accomplish. If you want to set the first part of the string up to maxlength you can do something like this:

Public Function SetLimit(ByRef test_object, ByRef Value)
    max = test_object.GetROProperty("max length")
    If Len(Value) > max Then
        test_object.Set Left(Value, max)
    Else
        test_object.Set Value
    End If
End Function
RegisterUserFunc "WebEdit", "Set", "SetLimit"
0
votes

You could use the WScript shell object to send keystrokes to the WebEdit after focussing it (by clicking into it). Like shown in http://h30499.www3.hp.com/t5/Quality-Center-Support-and-News/QTP-cannot-input-value-to-Webedit-field/td-p/4206627#.UkRMyIbIYyg:

Set WshShell = CreateObject("WScript.Shell")
Browser("Sarit_2").Page("Sarit").WebEdit("frm_vendor_address1").Click
WshShell.SendKeys(dtVAdd1)
Set WshShell = Nothing

Note that dtVAdd1's value must then conform to the format SendKeys expects -- as documented in (for example) http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.84).aspx.

Alternatively, you could use the undocumented Mercury.DeviceReplay interface to send the keystrokes. This is easily googleable.

0
votes

As we know WebEdit does not supports Type method, we can use alternate approach like

1.SendKeys
Set objClick = CreateObject("WScript.Shell") Browser("Sarit_2").Page("Sarit").WebEdit("frm_vendor_address1").Click
objClick.SendKeys "dtVAdd1"
Set objClick = Nothing

http://www.ufthelp.com/2013/02/sending-keyboard-strokes-in-uft-115.html

2.Using Native Object properties Browser("Sarit_2").Page("Sarit").WebEdit("frm_vendor_address1").object.value ="dtVAdd1" but this is almost similar to Set method

3.Using Advance Run settings in UFT

Tools->options->GUI Testing ->Web->Advance->Run Settings->Replay Type ->Mouse