Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have been searching for about an hour so I thought I would give this a shot.

I have an html page similar to this this:

<table>
<tbody>
<tr>
<td>
<input name="bla1" type="hidden" value="0" />
<input name="bla1" type="text" value="find me" />
</td>
<td>   
<input name="other" type="text" value="find me" />
</td>
</tr>
.
.
.
.
</tbody>
</table>

That is the basic structure. Now what I want to do is verify that (in the last row of the table) the second input element from the first td element has the value attribute set to "find me"
Each table row is like this. But I need to do this for only the last row.

So far I have this which is not working:
assertText | xpath=//table[1]//tr[last()]/td[1]/input[@value='.....'] | ......
where the ... represents what I am trying to verify.
There is only one table on the website. I am trying to verify a certain string is or is not present.

Thank you

share|improve this question
    
have you tried giving the input an id? id="whateverYouHaveTheInputFor". That way selenium can reference it directly.. –  lukeocom Mar 13 '13 at 6:22
    
I can't change the html source code.. –  Marky17 Mar 13 '13 at 22:59
    
Also it is possible for another row to have the same value I am looking for... but I need to check the last row in the table.. –  Marky17 Mar 13 '13 at 23:02
add comment

3 Answers

Is that xpath working? You definitely don't want [@value='.....'] at the end of it, you want to find the input regardless of the value. so you can assert that the value is ...

Use the Find button at the end of the target input in the IDE

try assertValue instead of assertText, a quick test shows that assertText won't work even if you've got the right input

Hope this helps

share|improve this answer
add comment

If you set an id to the input field, you can then use verifyValue

html

<input name="other" type="text" value="find me" id="find" />

selenium IDE:

  • command: verifyValue
  • target: id=find
  • value: find me

alternatively, if the name value you are using is unique, you can use that.

  • target: name=other
share|improve this answer
    
Neither of those would work because I cannot change the source code and.. the name value is unique but there is no way for me to know what it is. The name is really something like this "[5].category" but it skips numbers sometimes. Probably because of being deleted. So I don't know if the next row will be [6].category or something else because it could have been deleted before. –  Marky17 Mar 13 '13 at 23:08
add comment
up vote 0 down vote accepted

So I ended up finding the answer. My problem was that I did not understand xpath. I spent a little time on W3schools website http://www.w3schools.com/xpath/xpath_intro.asp. Very helpful.
Also, thank you @chim for mentioning assertValue. That was part of my problem.

Any who here is the answer specific to my case:
assertValue | //table[1]//tr[last()]/td[1]/input[2]/@value | textToVerifyHere

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.