Question

I have written a simple script to log into a Java app where it fills in username and password, and then clicks on the "Connect" button".

Set UVC = JavaDialog("UVC")
wait(20)
If UVC.Exist Then
    UVC.JavaEdit("JTextField").Set "admin"
    wait(2)
    UVC.JavaEdit("PSW").SetSecure "5256833195fsdqsdsqd447e4beefsdsdqd"
    wait(5)
    UVC.JavaButton("Connect").Click
Else
    print "Console is not present"
End If

It's strange as QTP is identifying my password field properly. When running the following code I get a value back as expected:

MsgBox Main.JavaEdit("password").GetROProperty("attached_text")

I have also tried to set the password without encrypting it but it's also not working.

PS: the same script was working before and has since stopped working for an unknown reason!!!

Thanks in advance.

Was it helpful?

Solution 3

Thanks for your answers but none of your suggestions worked, I have ended up using a basic turnaround :

UVC.JavaEdit("JTextField").Set"admin"
UVC.JavaEdit("PSW").Click 1,1
UVC.JavaEdit("PSW").SetSecure"52581237d889935df36ae78587773a641f40"
UVC.JavaButton("Connect").Click
wait (5)
While JavaDialog("Login Error").Exist 
JavaDialog("Login Error").JavaButton("Ok").click
UVC.JavaEdit("PSW").RefreshObject
UVC.JavaEdit("PSW").SetSecure"52581237d889935df36ae78587773a641f40"
UVC.JavaButton("Connect").Click
Wend

I really don't get it how could the same function work sometimes and sometimes not!!

OTHER TIPS

Replace

UVC.JavaEdit("PSW").SetSecure "5256833195fsdqsdsqd447e4beefsdsdqd"

with

UVC.JavaEdit("PSW").Click 1,1
UVC.JavaEdit("PSW").SetSecure "5256833195fsdqsdsqd447e4beefsdsdqd"

and it will work even with replay mode = "event". If you want to beautify this, you can use a click in the middle of the field, like in:

With UVC.JavaEdit("PSW")
    .Click .GetROProperty ("width")\2, .GetROProperty ("height")\2
    .SetSecure "5256833195fsdqsdsqd447e4beefsdsdqd"
End With

It seems that most Java password fields must first be focussed to be SetSecure-able.

Just to be sure.. check whether the field is enabled by testing .getroproperty("editable").

Use any of these methods to set text in Java Edit field.

  1. You could use JavaEdit("PSW").Object.Settext method - this uses the JTextField in JavaSwing object properties
  2. You could use setfocus method before entering the string in the field
  3. Get the position of the test field

x = JavaEdit("PSW").Getroproperty("abs_x")
y = JavaEdit("PSW").Getroproperty("abs_y")
Set DRP = CreateObject("Mercury.DeviceReplay")
DRP.MouseClick x,y,"0"
DRP.SendString "the string"

  1. You could also use JavaEdit's type object

Any of these methods should work for you. If not tough luck.. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top