Ask a Question

FindChildByXPath

SOLVED
aa1
Contributor

FindChildByXPath

Hi all,

 

I am a newbie on testcomplete. I am trying to use the FindChildByXPath to find/validate the title of the page. I am not sure what is wrong in this line. The error I get says 'label' is undefined. I have made sure that the classname is correct and ttl does populate the correct title name. All the line is supposed to do is to trturn back the obj so that next step I can compare the obj.contentText with the page title and confirm that it is the same.

 

obj = page.FindChildByXPath("//DIV[@class='classnameforrightColumn']/descendant-or-self::*[contains(text(),'" + CutOffString(ttl) + "')]");

 

Any ideas anyone? 

 

thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
aa1
Contributor

Re: FindChildByXPath

Hi @TanyaYatskovska ,

 

The issue solved by itself without me changing anything. I had updated the code base from the trunk. Seems that a change in some other part of the code got this issue fixed as well. Since I new to this and the project, I dont still have the full picture. But I think we can mark this as resolved since the issue is not there any more.

 

thanks

View solution in original post

6 REPLIES 6
K_Sathish_Kumar
Contributor

Re: FindChildByXPath

Hi @aa1 ,

 

if your requirment is to retrive the title of the page please find the below code snippeet.

function getPageTitle()
{
var page = Sys.Browser("chrome").Page("https://support.smartbear.com/*");
Log.Message(page.contentDocument.title);
}

Kind Regards,

Sathish Kumar

Regards,
Sathish Kumar K
AlexKaras
Community Hero

Re: FindChildByXPath

Hi,

 

As it is documented and was mentioned here several times, search by XPath in TestComplete can return either wrapper object with all properties and methods added by TestComplete or native DOM object. In the latter case (which seems to be yours) you may use only native DOM methods and properties (potentially - browser specific: https://support.smartbear.com/testcomplete/docs/app-testing/web/general/cross-browser/handling-diffe...).

For example: https://community.smartbear.com/t5/TestComplete-Functional-Web/Using-Xpath-in-TestComplete/m-p/15123...

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
aa1
Contributor

Re: FindChildByXPath

Hi Sathish,

 

Thank you for the reply. Actually I am not looking for the title of the page. I need to have the title in one of the divs/page section. So this code will not work for me. I need to play with the id or the class of the div but I am not able to figure out how to do that.

 

Anyway, thanks for the suggestion.

 

aa

aa1
Contributor

Re: FindChildByXPath

Hi,

 

Thank  you for the suggestion. I understand the downside. I will see what I can do.

 

thanks

aa

TanyaYatskovska
Community Manager

Re: FindChildByXPath

Hi @aa1,

 

Do you mind sharing with us the solution you decided to use?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
aa1
Contributor

Re: FindChildByXPath

Hi @TanyaYatskovska ,

 

The issue solved by itself without me changing anything. I had updated the code base from the trunk. Seems that a change in some other part of the code got this issue fixed as well. Since I new to this and the project, I dont still have the full picture. But I think we can mark this as resolved since the issue is not there any more.

 

thanks

View solution in original post

cancel
Showing results for 
Search instead for 
Did you mean: