Skip to content

Library internal argument conversion with Robot Framework API #4109

Closed as duplicate

Description

@aaltat

Browser library has similar run on failure support as SeleniumLibrary has, but Browser library supports arguments with the Register Keyword To Run On Failure keyword. But because registered keyword arguments can be almost anything, Browser library can not define typing for the arguments and therefore Robot Framework can not perform automatic conversion to the arguments. There is an issue which demonstrates the problem when we do not perform the conversion.

Therefore I was thinking to do conversion inside of the library. I think it can be done if the run on failure keyword is one of the browser library keywords, because then library knows the argument specification. But the argument conversion is pretty complex problem to do, so I was thinking that I could use some Robot Framework code. Is there some entry point which would allow to do the conversion easily?

Activity

  1. pekkaklarck commented on Oct 5, 2021

    @pekkaklarck
    Member

    Exposing argument conversion publicly would be a good idea. Not exactly sure what's the best API for that, though. Anyway, something that could be added in RF 5.0.

  2. added this to the v5.0 milestone on Oct 5, 2021
  3. removed this from the v5.0 milestone on Mar 4, 2022
  4. pekkaklarck commented on Mar 4, 2022

    @pekkaklarck
    Member

    Could you @aaltat clarify this request a bit more? I checked the linked Browser library issue and notice it was fixed already. Was this issue not relevant or was there some existing way to handle conversion?

    I removed this from RF 5.0 scope because we'd like to get that release out ASAP and because I'm not sure what we actually should even do to address this. If there's something concrete to do, this issue can be added to RF 5.1 scope.

  5. pekkaklarck commented on Mar 4, 2022

    @pekkaklarck
    Member

    I don't actually understand the whole need for argument conversion in Browser side. AFAIK it uses BuiltIn.run_keyword and it should handle conversion based on the type information of the called keyword automatically. For example, if I have a dummy library like

    from robot.libraries.BuiltIn import BuiltIn
    
    
    def kw1(arg: int):
        assert arg == 42
    
    
    def kw2(arg):
        BuiltIn().run_keyword('kw1', arg)

    I can use it as follows and 42 is converted to an integer correctly.

    *** Test Cases ***
    Example
      kw2    42

    BuiltIn.run_keyword is a pretty bad API for running other keywords, though, as #4237 explains. If we add a new and better API, need to take conversion into account with it.

  6. aaltat commented on Mar 9, 2022

    @aaltat
    ContributorAuthor

    When keyword originates from the same library, arguments are not problem. But keyword is not from same library arguments are problematic because args can be almost anything and then it get pretty complicated how that works. Or is there some shortcut to happiness which I do not see?

  7. pekkaklarck commented on May 20, 2025

    @pekkaklarck
    Member

    It seems that #4942 proposed the same thing and it was implemented in RF 7.0.

  8. pekkaklarck commented on May 20, 2025

    @pekkaklarck
    Member

    @aaltat agreed. Closing.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions