Skip to content

Some keywords do not work if text argument is not string #1021

Closed

Description

@aaltat

If I have this page:

<html>
    <div>1</div>
</html>

When I have this test case:

*** Settings ***
Library           Selenium2Library

*** Test Cases ***
Example
    Open Browser    /path/to/example.html    Chrome
    Wait Until Page Contains    ${1}
    [Teardown]    Close Browser

When I run the test case with Selenium2Library 1.8.0 the test passes. When I run the same test case with 3.0.1 release, then I see this error:


18:35:00.405    FAIL    TypeError: argument of type 'int' is not iterable   
18:35:00.405    DEBUG   Traceback (most recent call last):
  File "c:\python27\lib\site-packages\SeleniumLibrary\__init__.py", line 360, in run_keyword
    return DynamicCore.run_keyword(self, name, args, kwargs)
  File "c:\python27\lib\site-packages\SeleniumLibrary\base\robotlibcore.py", line 102, in run_keyword
    return self.keywords[name](*args, **kwargs)
  File "c:\python27\lib\site-packages\SeleniumLibrary\keywords\waiting.py", line 66, in wait_until_page_contains
    timeout, error)
  File "c:\python27\lib\site-packages\SeleniumLibrary\keywords\waiting.py", line 220, in _wait_until
    self._wait_until_worker(condition, timeout, error)
  File "c:\python27\lib\site-packages\SeleniumLibrary\keywords\waiting.py", line 227, in _wait_until_worker
    if condition():
  File "c:\python27\lib\site-packages\SeleniumLibrary\keywords\waiting.py", line 64, in <lambda>
    self._wait_until(lambda: self.is_text_present(text),
  File "c:\python27\lib\site-packages\SeleniumLibrary\base\context.py", line 81, in is_text_present
    locator = "xpath://*[contains(., %s)]" % escape_xpath_value(text)
  File "c:\python27\lib\site-packages\SeleniumLibrary\utils\__init__.py", line 27, i

Activity

  1. added this to the v3.1.0 milestone on Dec 14, 2017
  2. added a commit that references this issue on Dec 20, 2017
  3. aaltat commented on Dec 20, 2017

    @aaltat
    ContributorAuthor

    I did read code and noticed that we are not constant on the matter. With some keywords number is OK and with other it is not OK to have a number.

    This would be good time to decide what object types we do actually support. I my opinion, we should support str. Then I might be willing support number and nothing else. Nothing else covers False, None and other Python object types. Also for non supported types we should raise TypeError.

    Also instead of implementing this change for all keywords separately, we should find a unified way to implement this for all required keywords and for their arguments.

  4. pekkaklarck commented on Dec 20, 2017

    @pekkaklarck
    Member

    I'm afraid validating types is too much work compared to benefits. At least until we can drop Python 2 support and add type annotations to the code and do validation automatically. Until that I'd simply use arguments that are expected to be strings directly as strings (e.g. arg.upper() not str(arg).upper()).

  5. aaltat commented on Dec 20, 2017

    @aaltat
    ContributorAuthor

    That is true, Python 3 only support would make this more easier to implement and support. But that is not going to be implemented until core framework drops Python 2 support. Will we return to the issue in 2020?

  6. pekkaklarck commented on Dec 20, 2017

    @pekkaklarck
    Member

    I'd say so.

  7. removed this from the v3.1.0 milestone on Dec 24, 2017
  8. rubygeek commented on Apr 13, 2018

    @rubygeek
    Contributor

    shouldn't Wait Until Page Contains always expect to convert its arg to a string if it is not? the web document is a string right?

  9. aaltat commented on Apr 13, 2018

    @aaltat
    ContributorAuthor

    Well, it used to work and fixing it for one keyword is trivial, but fixing it to all keywords is not trivial. What documentation you are referring to?

  10. changed the title [-]Wait Until Page Contains keyword does not work if text argument is not string[/-] [+]Some keywords do not work if text argument is not string[/+] on Apr 20, 2018
  11. aaltat commented on Feb 26, 2019

    @aaltat
    ContributorAuthor

    This issue can be fixed when Robot Framework 3.1 is the minimum required version.

  12. added this to the v5.0.0 milestone on Sep 28, 2020
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