Micro Focus QTP (UFT) Forums
UFT doesn't recognize object in SAP at first, but recognize it after i click debug - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: UFT doesn't recognize object in SAP at first, but recognize it after i click debug (/Thread-UFT-doesn-t-recognize-object-in-SAP-at-first-but-recognize-it-after-i-click-debug)



UFT doesn't recognize object in SAP at first, but recognize it after i click debug - CedricMab - 08-03-2016

Hello,

I work on UFT 12.52 build 6851 with SAP 730
I already have some tests, and now i want to create a test that will launch SAP and login. When i get to the connection window, UFT cannot recognize the object.
What is really weird is that if i click on debug and then just after click the play button UFT will recognize the object.
Moreover, i noticed that if the SAP Logon window is already opened, UFT will find the connection at first try.

Thanks a lot for any insight you might have,
Cédric.

Error message :
[Image: 123741Capture.png]

My object repository is as follows, i can show you the other objects but the error message speak about the "session" object :
[Image: 47732461OR.png]

My code really isn't that particular, but if you need to see it :

Code:
If DataTable.GlobalSheet.GetCurrentRow = 1 Then
reporter.ReportEvent micDone,"Version", "Utilisation of action : '" & actionName & "' in the version : '" & version & "'"

SystemUtil.Run "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe","","C:\Program Files (x86)\SAP\FrontEnd\SAPgui",""   'Open SAP
Dialog("SAP Logon 730").WinListView("SysListView32").Activate DataTable("Server", dtGlobalSheet)  'Open the connection to the desired server
SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Client").Set DataTable("Client", dtGlobalSheet)    'Line that gets the error
SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("User").Set DataTable("User", dtGlobalSheet)
SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Password").Set DataTable("Password", dtGlobalSheet)
SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Logon Language").Set DataTable("Language", dtGlobalSheet)
SAPGuiSession("Session").SAPGuiWindow("SAP").SendKey ENTER
End If



RE: UFT doesn't recognize object in SAP at first, but recognize it after i click debug - Ankur - 08-04-2016

A couple of things you can try -

  1. After Dialog() statement , can you put some wait(5). [We can optimize timing later.]
  2. As soon as SAPGUISession() window is opened, try getting the hwnd of it. Using Activate method activate the window to get it in foreground and then follow through rest of the steps.
Let us know if these work for you!


RE: UFT doesn't recognize object in SAP at first, but recognize it after i click debug - CedricMab - 08-04-2016

Hi,


Setting a wait statement didn't correct the bug.

For the hwnd, i copied the code you provided but it didn't worked. Maybe i didn't implement it correctly however. I'm not really sure.

Code:
    'Step1: Simulate your action to bring the popup window
    'Click on the OK button in Login window which will simulate the popup window.
    SystemUtil.Run "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe","","C:\Program Files (x86)\SAP\FrontEnd\SAPgui",""
    Dialog("SAP Logon 730").WinListView("SysListView32").Activate DataTable("Server", dtGlobalSheet)
    'Step 2: Get the HWND of the popup window (assuming that the popup window is the top most window)
    'Declare the extern
    extern.Declare micLong,"GetForegroundWindow","user32.dll","GetForegroundWindow"
    'Get the top most window hwnd
    hwnd = extern.GetForegroundWindow()
    'Step 3: Assign the HWND value to the Object in OR.
    'set the hwnd value in object repository
    SAPGuiSession("Session").SetTOProperty "hwnd",hwnd
    'Step 4: Continue working with popup window as usual
    'perform operation on the top most window objects.
    SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Client").Set DataTable("Client", dtGlobalSheet)
    SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("User").Set DataTable("User", dtGlobalSheet)
    SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Password").Set DataTable("Password", dtGlobalSheet)
    SAPGuiSession("Session").SAPGuiWindow("SAP").SAPGuiEdit("Logon Language").Set DataTable("Language", dtGlobalSheet)
    SAPGuiSession("Session").SAPGuiWindow("SAP").SendKey ENTER



RE: UFT doesn't recognize object in SAP at first, but recognize it after i click debug - nguyen4685 - 02-06-2017

Sorry, i know that this thread is quite old, but i have the same problem by trying to select/activate an object in SAP

could you fix this problem? if yes, please tell me how to fix it

thanks