cancel
Showing results for 
Search instead for 
Did you mean: 

Click a variable

SOLVED
kaiiii
Regular Contributor

Click a variable

How can i Click a variable, suppose
Dim b

b = "Hi How are you"

 

 

Now this string is shown on a page....how can i make an object for it so i can use click method

1 ACCEPTED SOLUTION

Accepted Solutions
jose_pjoseph
Contributor

Re: Click a variable

Also, if you want to specifically use the variable, and don't mind using xpath, you can do the following:

 

dim b, obj, xpath

b = "Hi How are you"
xpath = "//*[text()='" & b & "']"
Set page = Sys.Browser("*").Page("*")
Set obj = page.FindChildByXPath(xpath)

If the variable sting is not unique and there is more than one element in your page with the string, you will have to modify the xpath to get the desired object.

View solution in original post

2 REPLIES 2
tristaanogre
Community Hero

Re: Click a variable

OK... have you tried recording what you want to accomplish?  That is always a good way to figure out how TestComplete interacts with your application after which you can make whatever modifications you want.

 

In this case... there's text on a web page... that text is inside of some web object (TextNode, Panel, Link, etc).  You need to find the pathing to that object (in TestComplete that can be found in the Object Browser and, most likely, in the NameMapping that your record generated).  You then do the following:

 

//with Name Mapping

Aliases.browser.pageMyPage.panal0.panal1.TextNode0.Click()

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
jose_pjoseph
Contributor

Re: Click a variable

Also, if you want to specifically use the variable, and don't mind using xpath, you can do the following:

 

dim b, obj, xpath

b = "Hi How are you"
xpath = "//*[text()='" & b & "']"
Set page = Sys.Browser("*").Page("*")
Set obj = page.FindChildByXPath(xpath)

If the variable sting is not unique and there is more than one element in your page with the string, you will have to modify the xpath to get the desired object.

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors