You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Some keywords do not work if text argument is not string #1021
*** 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
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.
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()).
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?
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
Activity
Fix for robotframework#1021:Wait Until Page Contains keyword does not…
aaltat commentedon Dec 20, 2017
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 supportnumberand nothing else. Nothing else coversFalse,Noneand other Python object types. Also for non supported types we should raiseTypeError.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.
pekkaklarck commentedon Dec 20, 2017
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()notstr(arg).upper()).aaltat commentedon Dec 20, 2017
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?
pekkaklarck commentedon Dec 20, 2017
I'd say so.
rubygeek commentedon Apr 13, 2018
shouldn't
Wait Until Page Containsalways expect to convert its arg to a string if it is not? the web document is a string right?aaltat commentedon Apr 13, 2018
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?
[-]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[/+]aaltat commentedon Feb 26, 2019
This issue can be fixed when Robot Framework 3.1 is the minimum required version.