Question

I am using the following code to get the id of a row that is randomly generated:

string[] rowIds = new string[numofRowsPassengerTable];
for (int counter=1; counter < numofRowsPassengerTable; counter++)
{
    rowIds[counter] = browser.GetAttribute("xpath=//table[@id='tblPassengers']/tbody/tr[counter]@id");
}

But the above is not returning anything. If I use 1 or 2 instead of counter it returns the id. Any idea how can I use that counter to get row ids?

Était-ce utile?

La solution

Looks like you wanted to actually use "counter" as a variable in the xpath string:

browser.GetAttribute("xpath=//table[@id='tblPassengers']/tbody/tr[" + counter + "]@id");

As it stands now, you tell the XPath engine to use some "counter" HTML element as index to the TRs, which obviously won't work.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top