robotframework icon indicating copy to clipboard operation
robotframework copied to clipboard

RF version 4 and above:Suspended due to logged failure: ValueError: Argument 'timeout' got value '0.5s' that cannot be converted to None.

Open ac57486 opened this issue 2 years ago • 5 comments

In RF version 4 and above, I am getting exception when using "Wait Until Page Contains Element" inside run_keyword_and_return_status as given below :

result = BuiltIn().run_keyword_and_return_status("Wait Until Page Contains Element", element, '0.5s')

Suspended due to logged failure: ValueError: Argument 'timeout' got value '0.5s' that cannot be converted to None. Not getting this error in earlier version 3.2.2.

But this works fine if I use wait_until_page_contains_element: sl = BuiltIn().get_library_instance('SeleniumLibrary') sl.wait_until_page_contains_element(element, '0.5s')

Example:

*** Keywords ***
Wait Until Page Contains One Of The Elements    ${sfc_lnk_element1}    ${sfc_lnk_element2} 

Python Library

@keyword
def wait_until_page_contains_one_of_the_elements(*elements, timeout=10):
    result = False
    count = len(elements)
    for index in range(0, int(timeout), int(count*0.5)):
        for element in elements:
            result = BuiltIn().run_keyword_and_return_status("SeleniumLibrary.Wait Until Page Contains Element", element, '0.5s')
            if result:
                break
    if not result:
        BuiltIn().fail('Page could not find any of the elements specified')

Please help me with this issue.

ac57486 avatar Jul 14 '22 15:07 ac57486

@pekkaklarck I am also getting error when using Wait Until Page Contains Element directly in RF 5.0. PFA for the same: image

ac57486 avatar Jul 18 '22 07:07 ac57486

Can anyone please look into this issue. Because of this issue, I'm not unable to use RF version 5

ac57486 avatar Jul 21 '22 12:07 ac57486

This looks pretty strange. I cannot run the example without modifications myself and don't have time to create a simpler example myself now. I'll look at this again after my holidays.

It seems to me you don't really need to use BuiltIn().run_keyword_and_return_status. You could instead just use something like

sl = BuiltIn().get_library_instance('SeleniumLibrary')
try:
    sl.wait_until_page_contains_element(element, '0.5s')
except WhateverExceptionIsRaisedIfThereIsTimeout:
    pass
else:
    break

pekkaklarck avatar Jul 21 '22 17:07 pekkaklarck

I tested this with the following very simple library and couldn't reproduce the problem. Element css:h1 used below existed but I also tested with css:h5 that doesn't and in both cases everything went as expected. I used SeleniumLibrary 6.0 i.e. the latest available version.

from robot.libraries.BuiltIn import BuiltIn


def kw():
    element = 'css:h1'
    BuiltIn().run_keyword_and_return_status("SeleniumLibrary.Wait Until Page Contains Element", element, '0.5s')

Could you test does the problem occur for you with Robot Framework 5.0.1 and SeleniumLibrary 6.0? If it does, try downgrading Robot and see does it resolve the issue. If you can reliably reproduce the problem with new Robot versions and it doesn't occur with older, please try to create a simple but concrete example I could run locally to reproduce it as well.

pekkaklarck avatar Aug 05 '22 08:08 pekkaklarck

@pekkaklarck As suggested, I will try to upgrade selenium library and update you very soon

ac57486 avatar Aug 08 '22 11:08 ac57486

I couldn't reproduce the issue and there hasn't been new info in a week. Closing now. Can be reopened if there's new info that indicates there's a bug on Robot side.

pekkaklarck avatar Aug 15 '22 12:08 pekkaklarck

@pekkaklarck Updating robotframework-selenium library resolved the issue. Earlier I was using 4.4.0 version with RF 5.0.1 that might be the issue Thanks much

ac57486 avatar Aug 22 '22 07:08 ac57486