1
votes

Am using robot framework in python to create keyword which internally uses selenium2library keywords.

I see an issue in the below code piece which is present inside my python keyword definition module.

status = BuiltIn().run_keyword_and_continue_on_failure(sel.click_button('wlbasic_11n_value_01'))

Here, lbasic_11n_value_01 is the id of the element of which is to be clicked.

I want my keyword to get executed even if this click button fails, thus am using run_keyword_and_continue_on_failure keyword.

Interestingly, the click of the button happens but then i see an error message saying the keyword name should be a string.

when is make sel.click_button('wlbasic_11n_value_01') -> 'sel.click_button('wlbasic_11n_value_01')'

python keyword code ->

def check():
    sel = BuiltIn().get_library_instance('Selenium2Library')
    title = sel.get_title()
    BuiltIn().log_to_console('Making the Router Mode Change Now')
    status =      BuiltIn().run_keyword_and_continue_on_failure(sel.click_button('wlbasic_11n_value_01'))

the keyword does not get detected at all and click never works.

what am i missing here, am new to robot framework.

Any debug help would be deeply appreciated.

1

1 Answers

1
votes

Interestingly, the click of the button happens but then i see an error message saying the keyword name should be a string.

That message is telling you exactly what the problem is, why are you ignoring what it is telling you? run_keyword_and_continue_on_failure requires the string name of a keyword, and you are passing it a function (sel.click_button(...)).

There's no need to use run_keyword_and_continue_on_failure -- just put a try/except around the code, which will accomplish the same thing:

try:
    sel.click_button('wlbasic_11n_value_01')
except Exception as e:
    <handle or ignore the error however you wish here...>

If you prefer to continue to use run_keyword_and_continue_on_error, do what it says and provide the keyword as a string:

status =      BuiltIn().run_keyword_and_continue_on_failure(
    'Click Button', 'wlbasic_11n_value_01')
)