0 votes

Known control full element Path:

controlPath = "html[1]/body[1]/form[1]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[7]/td[1]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[1]/td[3]/span[1]"

Known target table full element path (target table is always static):

tragetTable = "html[1]/body[1]/form[1]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[1]/td[1]/table[1]"

the row number in the tertiary level table is row 7 as shown in the control path, however, sometime it is in row 6 or row 8. but still in the teriary level table, tbody[1].

Can we get the row number based on the path of the control we captured?

I used the

ans = Broswer(windowName).performXpathquery("substring-after(targetTable, controlPath)"),

println ans(1)

it should give me the answer like tbody[1]/ tr[7]/....../span[1].

but instead it gave me the inner text content whitch imbed within the element path. why is that?

 

is there a way to get the Row No. just using xpath or other method?

I was thinking using parseString, set "/" as delimiter (why when I use "/tr[" as delimiter, it only count "t"??)

rowNo = parseString(controlPath, "/")

for rowCount = 1 to arraySize(rowNo, 1)

println rowNo(rowCount)

next

then I check the output then I know it is the position is 14 which is rowNo(14)

I got the answer : tr[7]

And I need to parse string twice more to get the numebr 7, this method is not ideal at all. can you offer some solutions better than this stupid one?

have a look at the following and maybe you can have a better understanding.

 

Much appreciated!


asked Mar 16, 2016 in QA Wizard Pro by Leo

1 Answer

0 votes

In your case I would find the control using the "id" property on the "<span>" and then you can get the properties of the control which would include the Xpath property. Then you can look at the XPath string value and find the "<tr>" it is located in (doing a count of those "<tr>" values in your XPath variable.

Here is an example to find the control by id for a hyperlink / HRef:

'***************************************************************************************
'Click on link for bug recordid 1
'Find control using xpath
link = Window("Wysicorp  Bugs").GetControlFromXPathQuery("//a[@id='bug1']")
Window("Wysicorp  Bugs").HTMLLink(link).Click()

'Verify Info via Output Window
'Get Link Property to Print on debug output
strLinkID = Window("Wysicorp  Bugs").HTMLLink(link).Property("[id]")
PrintLn("Link Clicked for Bug# " + strLinkID)

strPopUpExists = Window("Message from webpage").Button("OK").WaitForExistsTimed(1000)
if strPopUpExists = "-1" then
    'Window Not Found
else
    'Window Found
    Window("Message from webpage").Button("OK").Click()
end if
'***************************************************************************************

 

answered Mar 16, 2016 by nico (8,200 points)
Now you will need to take the control property and get the XPath value and then parse it to get the row count. I do not have an example of that code.
Thank you for your answer. Nico
however, it is not What I am struggling with..
Can we get the rowNo. of the tr[rowNo] automatically ? instead of manually?  I know how to manually check it, as shown in my  question, but I need it automatically get the rowNo, not "tr[7]" just "7", because it is a loop in the fourth layer of my script.

 maybe I can put the qeustion in another way, how to get a value(rowNo) from a string(full path).

like I know the string is : "table[1]/tbody[1]/tr[X]/td[1]/"
I need to get the "X" without manually checking it.

Also, can we not usi the parseString()  function three times to get the?.
Can we do that?  
Thanks again
248 questions
262 answers
106 comments
2,047 users