views:

179

answers:

2

I've just started using Selenium-IDE (not looked at selenium-RC yet: if somebody tells me that that is the answer to my question I'll look at it)

One of the operations I'm testing generates some output in a table in the next HTML page, but the order of the rows is not predictable.

I can obviously use 'assertTextPresent', but I want to do a bit more, and check that various bits of text are in the same row.

What I would like to be able to do is to identify a tr by some content, and then use that tr in subsequent asserts; something like

storeExpression //table[@id='TABLE_6']/td[.='case_1']/.. row
assertText      ${row}     'Some text'
assertText      ${row}     'Some other text'

to check that 'Some text' and 'Some other text' occur in the same table row as 'case_1'.

I haven't got this to work so far, and I'm not sure whether it is possible, or what syntax to use if it is.

Has anybody managed to do this?

+1  A: 

you can use xpath=${row}

see http://stackoverflow.com/questions/403622/selenium-is-it-possible-to-concatenate-an-xpath-with-a-variable (second response)

ts
So it's storing the xpath expression in the variable? I hadn't thought of that. Thanks. But I like Dave Hunt's suggestion even more.
Colin Fine
Personally, I didn't know assignId before , it's too cool!
ts
+3  A: 

You can use the assignId command to temporarily assign a value to the element's id attribute. For example:

assignId | //table//td[.='case_1']/.. | myRow
assertText | id=myRow | Some text
assertText | id=myRow | Some other text
Dave Hunt