Skip to content

Allow keywords to return None #51

@dpsfrishberg

Description

@dpsfrishberg

Sometimes, in the course of Robotic events, a page object method needs to return None. We currently require that all keywords return either self, an instance of another page class, or, at least, some value other than None. This is so that page object authors are consciously deciding whether their keyword switches to a new page. This causes a problem, though, when the actual return value of a getter needs to be None, which is sometimes the case. This exception often gets in the way of debugging other problems in a test, forcing knowledge of this requirement on test authors.

After discussion with @hellmanj, we decided that this is likely more common than the problem we are trying to prevent: namely, you use a keyword that should take you to a new page, but the page object author forgot to return that page, and so you get the old page's version of the keyword instead of the new one. (This only happens if two pages define the same keyword that does slightly different things. Otherwise, you'll just get a message saying the keyword you tried to use couldn't be found.)

Therefore, we should take out the code (https://github.com/ncbi/robotframework-pageobjects/blob/master/robotpageobjects/page.py#L53, https://github.com/ncbi/robotframework-pageobjects/blob/master/robotpageobjects/page.py#L294) that requires returning a page object.

@hellmanj also suggests augmenting the exception that tells you that a keyword couldn't be found, with something reminding you that you need to return a page object from each keyword that takes you to a new page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions