Search code examples
vbscriptqtphp-uft

QTP recognising a JavaEdit object but not able to set a value when running the script


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.


Solution

  • 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!!