cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
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 | LinkedIn |Vallalarasu.p@gmail.com
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

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

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

View solution in original post

4 REPLIES 4
Highlighted
Community Hero

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

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
Highlighted
Community Hero

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

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

View solution in original post

Highlighted
Frequent Contributor

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

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 | LinkedIn |Vallalarasu.p@gmail.com
Highlighted
Community Hero

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

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
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!

Retrieve Data from a Web Page

Participate!
Top Kudoed Authors