robotframework / OldSeleniumLibrary

Deprecated Selenium library for Robot Framework
Apache License 2.0
13 stars 3 forks source link

New `Element Text Should Be` keyword #137

Closed spooning closed 9 years ago

spooning commented 9 years ago

Originally submitted to Google Code by spielman... on 19 Sep 2010

There is a keyword "Element Should Contain" that verifies that a given text is contained inside the text of an element, e.g.

<p>The cat jumps over the dog</p>

contains cat, so that would pass, whereas it doesn't contain bird, so that test would fail.

I think it would be useful to also have a keyword "Element Text Should Be (Exactly)" or similar, which allows to verify that the given element contains exactly and only the text passed into the keyword. Thus, given

<p>You are now logged in.</p>

and the text "You are now logged in." would pass, and nothing else. Using "contains" is too tolerant in this case, because if it were like this:

<p>Object@⁠3e25a5You are now logged in.</p>

the test would still pass if I were to use "Element Should Contain".

I think this would be very easy to implement, because there would only have to be one small difference to element_should_contain - instead of:

if not excepted in actual

it would have to be

if not excepted == actual

in the new keyword.

spooning commented 9 years ago

Originally submitted to Google Code by @pekkaklarck on 20 Sep 2010

I actually thought there was a keyword like this for an exact match. If not, adding one definitely makes sense. Element Text Should Be sounds like a good keyword name.

spooning commented 9 years ago

Originally submitted to Google Code by spielman... on 21 Sep 2010

Here's a patch for that one as well. I have the changes for issue 136 and this issue in my local repo clone, so if they get your approval, I can push them and we have 2 new keywords :)

spooning commented 9 years ago

Originally submitted to Google Code by @pekkaklarck on 22 Sep 2010

Patch looks pretty good. Two doc enhancements:

There's also quite a bit duplication between the new keyword and Element Should Contain, but I'm not sure is eliminating it worth the effort.

spooning commented 9 years ago

Originally submitted to Google Code by spielman... on 23 Sep 2010

This issue was closed by revision fcc61f45d1.

spooning commented 9 years ago

Originally submitted to Google Code by spielman... on 23 Sep 2010

I've just pushed the changesets for this issue and issue 136 . The doc enhancements were incorporated and I also regenerated the HTML documentation.

spooning commented 9 years ago

Originally submitted to Google Code by @pekkaklarck on 23 Sep 2010

I didn't look at the final commits too closely but the original patches looked good. Changing status to Done, which we use instead of Fixed that is default on Google Code. Done works well with all issues and not just bugs.