Micro Focus QTP (UFT) Forums
Not working if not hard coded (web link).click - 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: Not working if not hard coded (web link).click (/Thread-Not-working-if-not-hard-coded-web-link-click)



Not working if not hard coded (web link).click - dlaureano - 02-08-2013

I'm new to QTP and I'm just trying to click a link in a web page and the "Click" only works if is hard coded. If I try to run [variable].click I receive the following error:
Object required: 'Browser("Main").Page'

Function file: Z:\KDF2\Function Library\FunctionLibrary.vbs
Line [170];"
control_object.click".


Code:
            Select Case sAction

            Case "Click_Link"
                 '   control_object = Browser("Main").Page("Main").Link("Members")    '<<--<<-- CONTROL_OBJECT VALUE
                    'Browser("Main").Page("Main").Link("Members").click '<<--<<-- HARD CODED RAN WITHOUT PROBLEM.
                control_object.click



RE: Not working if not hard coded (web link).click - pradeep singh - 02-11-2013

Try to use similar as given below:
Code:
control_object=trim(control_object)
Execute(trim(control_object & ".Click"))



RE: Not working if not hard coded (web link).click - ravi.gajul - 02-11-2013

Please use the "Set" keyword when creating object references.The code below should work.
Code:
Set  control_object = Browser("Main").Page("Main").Link("Members")
control_object.click