Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/Selenium2Library/keywords/_formelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,44 @@ def textfield_value_should_be(self, locator, expected, message=''):
raise AssertionError(message)
self._info("Content of text field '%s' is '%s'." % (locator, expected))

def textarea_should_contain(self, locator, expected, message=''):
"""Verifies text area identified by `locator` contains text `expected`.

`message` can be used to override default error message.

Key attributes for text areas are `id` and `name`. See `introduction`
for details about locating elements.
"""
actual = self._get_value(locator, 'text area')
if actual is not None:
if not expected in actual:
if not message:
message = "Text field '%s' should have contained text '%s' "\
"but it contained '%s'" % (locator, expected, actual)
raise AssertionError(message)
else:
raise ValueError("Element locator '" + locator + "' did not match any elements.")
self._info("Text area '%s' contains text '%s'." % (locator, expected))

def textarea_value_should_be(self, locator, expected, message=''):
"""Verifies the value in text area identified by `locator` is exactly `expected`.

`message` can be used to override default error message.

Key attributes for text areas are `id` and `name`. See `introduction`
for details about locating elements.
"""
actual = self._get_value(locator, 'text area')
if actual is not None:
if expected!=actual:
if not message:
message = "Text field '%s' should have contained text '%s' "\
"but it contained '%s'" % (locator, expected, actual)
raise AssertionError(message)
else:
raise ValueError("Element locator '" + locator + "' did not match any elements.")
self._info("Content of text area '%s' is '%s'." % (locator, expected))

# Public, buttons

def click_button(self, locator):
Expand Down
2 changes: 2 additions & 0 deletions src/Selenium2Library/locators/elementfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def _get_tag_and_constraints(self, tag):
elif tag == 'file upload':
tag = 'input'
constraints['type'] = 'file'
elif tag == 'text area':
tag = 'textarea'
return tag, constraints

def _element_matches(self, element, tag, constraints):
Expand Down