Highlighted
Absent Member.
Absent Member.
569 views

Object required in function library

Jump to solution

Hi all,

I am dealing with an issue I just can not wrap my head around. I have a simple action that stores value of an element into outgoing parameter which works fine and after that I call a function extReporter that handles capture screenshot and reporting to Reporter object. Here is the function I wrote:

 

' **************************************************
' Will perform page capture and report
' with desired status and description
' to Reporter class
' - objPage - Page object
' - status - micFail, micPass, micDone, micWarning
' - strStepName - step name for reporter
' - strDescription - description for event
' - strFilename - filename for screenshot
' **************************************************
Function extReporter(ByRef objPage, status, strStepName, strDescription, strFilename)
	MsgBox IsObject(objPage)

	Dim result
	Set result = objPage.CaptureBitmap(strFilename, True)
	Reporter.ReportEvent status, strStepName, strDescription, strFilename	
End Function

Problem is when called with "Set objbrowser = Browser("Webshop")" UFT will report "Object required: "objPage.CaptureBitmap(...)". Browser("Webshop") works in the action that calls extReporter and an identical MsgBox placed in the action will return True for IsObject(Browser("Webshop")). I tried setting a variable for browser to set but it yields the same result. This is my entire action thus far:

 

 

Parameter("CompareText") = Browser("Webshop").Page("Delivery list").WebElement("Postal delivery section").GetROProperty("innertext")
MsgBox IsObject(Browser("Webshop"))

Dim objbrowser
Set objbrowser = Browser("Webshop")
extReporter objbrowser, micFail, "test", "test", "test.png"

Additionally if I choose to debug the error and call the same line in inspector the screenshot is made without problems.

 

Any help would be greatlyappreciated.

Janez

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

I hate replying to my own posts. I tried one last attempt - reverting to simple call CaptureBitmap without setting object. It works. Function now works like this and works - which was the first version that worked for a while and then stopped.

Function extReporter(ByRef objPage, status, strStepName, strDescription, strFilename)
	objPage.CaptureBitmap strFilename, True 
	Reporter.ReportEvent status, strStepName, strDescription, strFilename	
End Function

View solution in original post

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

I hate replying to my own posts. I tried one last attempt - reverting to simple call CaptureBitmap without setting object. It works. Function now works like this and works - which was the first version that worked for a while and then stopped.

Function extReporter(ByRef objPage, status, strStepName, strDescription, strFilename)
	objPage.CaptureBitmap strFilename, True 
	Reporter.ReportEvent status, strStepName, strDescription, strFilename	
End Function

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.