Ask a Question

Xpath in Keyword Test, How to identify and perform operation on it ?

SOLVED
Vallalarasu_P
Frequent Contributor

Xpath in Keyword Test, How to identify and perform operation on it ?

How to find the object using xpath expression and performing operation on the found object ?

With Regards
Vallalarasu Pandiyan
https://www.linkedin.com/in/vallalarasupandiyan/
4 REPLIES 4
cunderw
Community Hero

I would highly advise against using Xpath in Test Complete and stick with the build object find methods and name mapping. What is the use case for wanting Xpath?


Thanks,
Carson

Click the Accept as Solution button if my answer has helped
tristaanogre
Esteemed Contributor

I agree with @cunderw .  Unless ABSOLUTELY necessary, you don't need to use XPath expressions to find objects in TestComplete tests.

 

IF, however, you need to....

 

1) Use "Call Object Method" operation in Keyword test to call the XPath method on your parent object

2) USe "Set Variable Value" operation to set the "Last Operation Result" to the value of your variable

3) Use that variable in code expressions and such within your keyword tests to identify your object

 

 

It's point 3 which makes using XPath expressions in keyword tests VERY cumbersome because you can't just use "On screen action"... everything needs to be a code snippet or code expression from that point onwards.  You might as well write in code rather than a keyword test.


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

Is the below steps possible in Keyword test

 

1) Maintaining Xpath in an external file (Excel or csv) / Project Variables for the list of object.

2) Creating a keyword test (XPathObject- Based on below steps)  to parametrize the Xpath value 

3) Calling the Keyword test (XpathObject) in each step of the test. 

 

Another option is, How to use FindChildbyxpath  in Script test and parametrizing it throught out the keyword test .

 

Regards

Valla

 

 

With Regards
Vallalarasu Pandiyan
https://www.linkedin.com/in/vallalarasupandiyan/

Yes, you can.  But again, USING the resulting XPath object and interacting with it via Click or Keys or other onscreen actions is a matter of running code snippets WITHIN the keyword test... that's really the only way to do it.  So, for that, if you MUST use XPath, it's best to write all your automation using a script language... just saves the headache, IMO.

 

Which begs the question: Why are you using XPath instead of NameMapping?


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
cancel
Showing results for 
Search instead for 
Did you mean: