0

I have a weird situation here and I am not able to find out the reason and fix.

I have written a script using HP UFT 11.52 for testing a .net web application on IE8

Here is the code:

If Browser(x).Page(x).Frame(x).WebEdit(abc).Exist(0) Then
    Browser(x).Page(x).Frame(x).WebEdit(abc).Click
    Set objSSN=Createobject("Wscript.Shell")
    objSSN.SendKeys" "
    Set objSSN=Nothing
    Browser(x).Page(x).Frame(x).WebEdit(abc).Object.Focus()
    Browser(x).Page(x).Frame(x).WebEdit(abc).Set 100-10-1000
End If

This code runs fine when I run the script after starting my windows laptop. If I run the same code the second time, the code will not enter the space and so does not enter the SSN. Now entering a space is required since clicking the webedit will result in a blank selection, so if I enter something with script it gives incorrect data.

My teammate who works on a virtual machine for running these scripts had no issues running this script on his machine. So I suspect there is some setting either in IE or windows somewhere which needs to be modified.

Can anyone help me identifying the issue.

Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
Zincloid
  • 11
  • 2

2 Answers2

0

To enter SSN in a textbox using QTP, do we have to really do a click & focus?

Below script should be fine.

If Browser(x).Page(x).Frame(x).WebEdit(abc).Exist(0) Then
    Browser(x).Page(x).Frame(x).WebEdit(abc).Set "100-10-1000"
End If
vins
  • 15,030
  • 3
  • 36
  • 47
  • I tried with the above code you mentioned Vinoth. But it did not work, I then tried sendkeys and entered a space, it worked. But now the issue seems to be different, it only works for the first time after I restart windows. – Zincloid Apr 29 '15 at 20:57
  • When you say it does not work - what is happening exactly? I am not understanding use of `sendkeys` in your case. If you need a space in the SSN textbox, `Browser(x).Page(x).Frame(x).WebEdit(abc).Set " "` . should work too. – vins Apr 29 '15 at 21:09
  • If i do not add a space and just set the value only then it randomly sometimes sets the value and sometimes it does not. If I manually click the field, it does not directly show the cursor blinking, instead it selects the whole webedit's empty spaces. Manually I have to click again to have the cursor displayed. If I do not repeat the exact same steps as I mentioned for the manual steps, it will not enter the data in the field. So i figured a space character would help, and it worked – Zincloid Apr 29 '15 at 23:31
  • Whatever the behavior you are saying - is this how it is supposed to work? – vins Apr 30 '15 at 02:52
0

Instead of sending a space try changing the replay type to device and then Set a space

If Browser(x).Page(x).Frame(x).WebEdit(abc).Exist(0) Then
    Setting.WebPackage("ReplayType") = 2 
    Browser(x).Page(x).Frame(x).WebEdit(abc).Set " " ' This may not be needed
    Browser(x).Page(x).Frame(x).WebEdit(abc).Set "100-10-1000"
    Setting.WebPackage("ReplayType") = 1 
End If
Community
  • 1
  • 1
Motti
  • 110,860
  • 49
  • 189
  • 262