Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide support for verifying text entered into a textarea element #167

Closed
stevejefferies opened this issue Feb 7, 2013 · 2 comments
Closed
Milestone

Comments

@stevejefferies
Copy link
Contributor

Currently S2L allows the verification of text fields through "Textfield Should Contain" and "Textfield Value Should Be" but this doesn't work for textarea elements since these keywords resolve to a tag of "input" in _get_tag_and_contraints. I tried "Element Text Should Be" and "Element Should Contain" keywords but these don't evaluate the text value currently set since these call _get_text rather that _get_value so there doesn't appear to be a way of evaluating the text you have input into a textarea field.

I have currently implemented an additional keyword locally along the lines of:

def textarea_should_contain(self, locator, expected, message=''):
    actual = self._get_value(locator, 'text area')
    try:
        if not expected in actual:
            if not message:
                message = "Text area '%s' should have contained text '%s' "\
                          "but it contained '%s'" % (locator, expected, actual)
                raise AssertionError(message)
    except TypeError:
        raise TypeError("Could not find element: {0}".format(locator))
    self._info("Text area '%s' contains text '%s'." % (locator, expected))

and modified _get_tag_and_constraints to allow a tag of 'text area' which returns a tag of 'textarea' which works for my needs. (also done for exact text matches in a separate keyword).
What are your thoughts on this implementation? Is it better to have a separate set of keywords for textarea elements? Or would it be better to allow support for textarea elements within the "Textfield Should Contain" keyword (and exact match keyword)?

Happy to submit a pull request for this modification if you think it's correct.

@j1z0
Copy link
Contributor

j1z0 commented Feb 8, 2013

I think keep it separate an your implementation looks great. I think you should submit the pull request and we will merge it.

Cheers,
Jeremy

On Feb 7, 2013, at 23:12, stevejefferies notifications@github.com wrote:

Currently S2L allows the verification of text fields through "Textfield Should Contain" and "Textfield Value Should Be" but this doesn't work for textarea elements since these keywords resolve to a tag of "input" in _get_tag_and_contraints. I tried "Element Text Should Be" and "Element Should Contain" keywords but these don't evaluate the text value currently set since these call _get_text rather that _get_value so there doesn't appear to be a way of evaluating the text you have input into a textarea field.

I have currently implemented an additional keyword locally along the lines of:

def textarea_should_contain(self, locator, expected, message=''):
actual = self._get_value(locator, 'text area')
try:
if not expected in actual:
if not message:
message = "Text area '%s' should have contained text '%s' "
"but it contained '%s'" % (locator, expected, actual)
raise AssertionError(message)
except TypeError:
raise TypeError("Could not find element: {0}".format(locator))
self._info("Text area '%s' contains text '%s'." % (locator, expected))
and modified _get_tag_and_constraints to allow a tag of 'text area' which returns a tag of 'textarea' which works for my needs. (also done for exact text matches in a separate keyword).
What are your thoughts on this implementation? Is it better to have a separate set of keywords for textarea elements? Or would it be better to allow support for textarea elements within the "Textfield Should Contain" keyword (and exact match keyword)?

Happy to submit a pull request for this modification if you think it's correct.


Reply to this email directly or view it on GitHub.

stevejefferies added a commit to stevejefferies/robotframework-selenium2library that referenced this issue Feb 8, 2013
emanlove pushed a commit to emanlove/robotframework-seleniumlibrary that referenced this issue Sep 2, 2013
@ghost ghost assigned emanlove Sep 2, 2013
@emanlove
Copy link
Member

emanlove commented Sep 2, 2013

Fixed in #168.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants