Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible for custom converters to get access to the library #4510

Closed
pekkaklarck opened this issue Oct 17, 2022 · 2 comments
Closed

Comments

@pekkaklarck
Copy link
Member

Custom converters are a handy feature added in RF 5.0 (#4088). It would be convenient if converters would be able to access the library they are attached to. This would allow conversion to be dependent on the state of the library or the automated application. For example, we web testing library could automatically check does a locator string (id, xpath, css, ...) match any object on the page and pass a reference to the object to the keyword.

A simple way to support this would be passing the library instance to the converter along with the value to be converted:

def converter(value, library):
    ...

For backwards compatibility reasons we cannot make the second argument mandatory and needing to use it in cases where it's not needed wouldn't be convenient in general. We can, however, easily check does the converter accept one or two arguments and pass it the library instance only in the latter case.

@pekkaklarck
Copy link
Member Author

pekkaklarck commented Oct 17, 2022

We already now check how many arguments the converter accepts to validate that the converter is valid. We currently require it to accept exactly one positional argument. For forward compatibility reasons we should make that validation a bit less string already in RF 6.0 so that the converter can accept more arguments as long as those arguments aren't mandatory. We should, for example, allow using converter(value, whatever='default').

@pekkaklarck
Copy link
Member Author

This feature still seems to lack documentation.

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

Successfully merging a pull request may close this issue.

2 participants