Skip to content

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

Closed

Description

@stevejefferies

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.

Activity

  1. j1z0 commented on Feb 8, 2013

    @j1z0
    Contributor

    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.

  2. ghost assigned on Sep 2, 2013
  3. emanlove commented on Sep 2, 2013

    @emanlove
    Member

    Fixed in #168.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions