Ask a Question

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


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

Occasional Contributor

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

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

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

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



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




Occasional Contributor

Thanks Marsha. Still have the same issue 

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



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")]



As a side note:

  /Alex [Community Champion]
[Community Champions] 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 Champions]
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 Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
Occasional Contributor

I am trying to




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)




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");



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





Please precise your locator more carefully:



Showing results for 
Search instead for 
Did you mean: