Micro Focus QTP (UFT) Forums
Click after CheckProperty to a WebElement passed via Function argument fails - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Click after CheckProperty to a WebElement passed via Function argument fails (/Thread-Click-after-CheckProperty-to-a-WebElement-passed-via-Function-argument-fails)



Click after CheckProperty to a WebElement passed via Function argument fails - naruoga - 02-28-2019

Hi,  I'm very new to UFT.

Now I have two scripts like:

Code:
Browser().Page().WebEdit("editBoxA").Set "SomeValue"
Browser().Page().WebEdit("editBoxA").CheckProperty "value","SomeValue"
Browser().Page().WebEdit("editBoxA").Click

and:

Code:
Browser().Page().WebEdit("editBoxB").Set "SomeValue"
Browser().Page().WebEdit("editBoxB").CheckProperty "value","SomeValue"
Browser().Page().WebEdit("editBoxB").Click

So I thought it would be nice if I can use Shared Library Function like:

Code:
Public Sub checkElement(ByRef element)
  element.Set "SomeValue"
  element.CheckProperty "value","SomeValue"
  element.Click
end
then each scripts could be:
Code:
checkClick Browser().Page().WebEdit("editBoxA")
But I got an error 

> Cannot identify the object "editBoxA" (of class WebEdit)

in the line "element.click".

I tried to comment out CheckProperty line, then it works fine.

Please someone let me know of my mistake, or more efficient code.