Ask a Question

Finding object by using dynamic xpath, using Partial Content text

muhammadA
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
muhammadA
Occasional Contributor

http://ui-grid.info/

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?

 

muhammadA
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 http://ui-grid.info/

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

id='150952

 

 

muhammadA
Occasional Contributor

Thanks Marsha. Still have the same issue 

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

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

Hi,

 

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

Regards,
  /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.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
muhammadA
Occasional Contributor

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;

}

 

Please precise your locator more carefully:

 

xpath.PNG

cancel
Showing results for 
Search instead for 
Did you mean: