cancel
Showing results for 
Search instead for 
Did you mean: 

Finding object by using dynamic xpath, using Partial Content text

Occasional Contributor

Finding object by using dynamic xpath, using Partial Content text

Hi all,

 

I have following dynamic xpath's

.//*[@id='1509527131388-grid-container']/div[2]/div
.//*[@id='1509528020936-grid-container']/div[2]/div
.//*[@id='1509528970483-grid-container']/div[2]/div
.//*[@id='1509528970483-grid-container']/div[2]/div

I am trying to find the object by

 

var obj = Sys.Browser("*").Page("*").FindChildByXPath(".//*[@id=150952'" + * + "'-grid-container']/div[2]/div]");

 

showing as syntax error. Can you please help me to find the error

17 REPLIES 17
Occasional Contributor

Re: Finding object by using dynamic xpath, using Partial Content text

http://ui-grid.info/

this is website I am trying to get the grid values from

Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

FindChildByXPath(".//*[@id=150952'" + * + "'-grid-container']/div[2]/div]")

 

You have three single quotes in there, one on each side of  + * + and one after -grid-container.  Do you need to match the one after -grid-container or take it out?

 

Occasional Contributor

Re: Finding object by using dynamic xpath, using Partial Content text

Hi Marsha,

 

.//*[@id='15095 "27131388" -grid-container']/div[2]/div
.//*[@id='15095 "28020936" -grid-container']/div[2]/div
.//*[@id='15095 "28970483" -grid-container']/div[2]/div
.//*[@id='15095 "28970483"-grid-container']/div[2]/div

 

The one in quatations is keeping changing , I want everything else into I want find the object containing

 

.//*[@id='15095 "*******"-grid-container']/div[2]/div.

 

Please verify http://ui-grid.info/

I am trying to get the Values from the upper grid present in the page.

 

 

Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

See attached.  I have marked the matching pairs of quotes in blue and the mismatched one in red.   

 

You need another single quote to match the one marked in red.  I believe it needs to go here

id='150952

 

 

Occasional Contributor

Re: Finding object by using dynamic xpath, using Partial Content text

Thanks Marsha. Still have the same issue 

  var obj = Sys.Browser("*").Page("*").FindChildByXPath(".//*[@id='150952'" + * + "'-grid-container']/div[2]/div]");

Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

Hi,

 

XPath won't recognize "*" as a wildcard.

 

You should use another approach. E.g. using the contains() function:

 

.//div[contains(@id, "150952") and contains(@id, "grid-container")]
Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

Hi,

 

As a side note: https://community.smartbear.com/t5/TestComplete-Functional-Web/Using-Xpath-in-TestComplete/m-p/15123...

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members 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. Postings made by [Community Expert Group] members
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.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Occasional Contributor

Re: Finding object by using dynamic xpath, using Partial Content text

I am trying to

 

Url: http://ui-grid.info/

 

Angualr UI grid

I am trying to get the values of the upper grid. I need to capture those values from the table and verify them with the values in Excel sheet in Test complete.

 

I used all the three types of finding the object,none of them worked.  Please verify following script and let me know where I am going wrong.

Thank you for co operation in advance

 

 

function VerifyGridValue(textValue)

{

  Sys.Browser("*").Page("*").Wait("10000");

 

var obj = Sys.Browser("*").Page("*").FindChildByXPath(".//*[@id='150952'" + * + "'-grid-container']/div[2]/div]");

//Sys.Browser("*").Page("*").FindChildByXPath("//*[@class='" + ui-grid-canvas + "']")

//var obj = Sys.Browser("*").Page("*").FindChildByXPath(".//*div[contains(@id, "150952") and contains(@id, "grid-container")]/div[2]/div]");

 

 var val=obj.wValue(0,1);

 

switch (true)

{

    case IsSupported(obj, val) == true && textValue :

          Log.Checkpoint("Value match as expected");

          break;

       default:

          Log.Error("Text values do not match!");

}

        Log.CallStackSettings;

}

 

Community Hero

Re: Finding object by using dynamic xpath, using Partial Content text

Please precise your locator more carefully:

 

xpath.PNG

New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2
Top Kudoed Authors