qentinelqi / qweb

Keyword driven automation for the web
https://github.com/qentinelqi/qweb
Apache License 2.0
40 stars 17 forks source link

Some keywords do not accept named first argument #64

Closed turunenm closed 2 years ago

turunenm commented 2 years ago

Describe the bug Keywords which internally use decorator QWeb.internal.decorators.timeout_decorator do not accept first argument (usually some kind of locator) as named argument.

When the first argument is given as a named argument exception QWebElementNotFoundError("Use \\= instead of = in xpaths") is always raised from method QWeb.internal.decorators._equal_sign_handler().

Some kws, such as Is Element allow the use of xpaths as named arguments. In the attached test case it is demonstrated that using xpath as named arguments = characters of xpaths do not need to be escaped

To Reproduce Run following rf test

*** Settings ***
Library    QWeb
Suite Setup    OpenBrowser    https://duckduckgo.com    chrome
Suite Teardown    Close All Browsers

*** Test Cases ***
Escaped named arg fails
    Click Element    xpath=//input[@id\="search_form_input_homepage"]

Unescaped named arg fails
    Click Element    xpath=//input[@id="search_form_input_homepage"]

Escaped unnamed arg passes
    Click Element    //input[@id\="search_form_input_homepage"]

Not decorated named arg passes
    Is Element    xpath=//input[@id="search_form_input_homepage"

Not decorated unescaped unnamed arg fails
    Is Element    //input[@id="search_form_input_homepage"

Not decorated escaped unnamed arg passes
    Is Element    //input[@id\="search_form_input_homepage"

Expected behavior Using named args instead of unnamed args should always work because robot framework and python generally accept the use of named args.

Environment Not dependent on environment

Additional context Fixing this bug allows passing xpaths as named arguments without escaping = character. See attached test case for examples.

Kw go_to has further specialized arg handling at _equal_sign_handler and refactoring it should addressed separately.

Kw open_browser does not allow arguments url or browser_alias as named arguments, but the origin of the bug is different and should be addressed separately.

turunenm commented 2 years ago

Recreated issue because the previous one was lost due to account suspension 😅

turunenm commented 2 years ago

Duplicates #62 Original issue was temporarily unavailable so a new issue was created and a PR was made. Because this issue had a PR the original issue was closed when it became available again.

tkoukkari commented 2 years ago

Closing this as it was included in 2.0.1 release.