Forum Discussion

AutoBot_1's avatar
AutoBot_1
Occasional Contributor
15 years ago

Problems using XPATH in TC 8.50

Dear TC Support,



Its really a helpful feature to use Xpath using TC 8.5 in identifying web objects.



However, I am facing some issues while identifying the Xpath for a few web objects that dont have an ID assigned to it.



Consider the scenario:

I want to click on the select flight button on Delta.com

To reach this step, you should goto www.delta.com; search for any flight; the next page goes to a URL as

http://www.delta.com/booking/findFlights.do#top



Check the attached snapshot of the webpage. I am trying to find the Xpath of the highlighted element using a Firefox plugin (Xpath Checker).

The Xpath given by this plugin works accurately in most cases when used with TestCompletes "EvaluateXpath" function.



(Note: I am using Firefox 3.6.x on Windows XP machine.)



However, in this case it is not working and gives and error when I give this as the Xpath-

id('td_selectFlightsSegment_0_0_0')/x:div/x:input



My code looks like -

objWebObject = objPage.EvaluateXPath("id('td_selectFlightsSegment_0_0_0')/x:div/x:input")



Can you please suggest a way to use Xpath in this case. (Am i missing any syntax or escape characters while giving this Xpath inside the function).



Please note I do not want to use the Find method to locate the object, that works for me and I am aware of that approach. I want to specifically use Xpath in this scenario.




3 Replies

  • AutoBot_1's avatar
    AutoBot_1
    Occasional Contributor
    Thanks a lot David.



    I really think that the Help contents for Xpath should be updated by giving out more examples and made more comprehensive.



  • Hi,



    Thanks for your suggestion about improving the help file. However, I think that the current content of the corresponding topic is enough. XPath expressions are not our invention and there is a lot of information in Internet about them. The XPath functionality was introduced in TestComplete especially for those users who are already familiar with XPath expressions and feels more comfortable using them then TestComplete's Find methods.