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 first argument as a named argument #62

Closed mturunen-copado closed 2 years ago

mturunen-copado commented 2 years ago

Describe the bug Keywords which use internally the decorator QWeb.internal.decorators.timeout_decorator raise exception QWebElementNotFoundError("Use \\= instead of = in xpaths") when giving the first argument as a named argument

For example (https://duckduckgo.com/ search text input) Click Element //input[@id\="search_form_input_homepage"] works when = characters of the xpath are escaped Click Element xpath=//input[@id="search_form_input_homepage"] will not work Click Element xpath=//input[@id\="search_form_input_homepage"] will not work even with escaped xpath

But Is Element which is not decorated by timeout_decorator accepts xpath as named argument. As unnamed arg the = characters of xpath need to be escaped as expected Is Element xpath=//input[@id="search_form_input_homepage" works Is Element //input[@id\="search_form_input_homepage" works Is Element //input[@id="search_form_input_homepage" does not work (expected not to work)

Bug originates from method QWeb.internal.decorators._equal_sign_handler(args, kwargs, function_name)

To Reproduce Create a following rf test and run it

*** 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 Passing arguments as named arguments should work universally because robot framework and python generally allow it

Desktop (please complete the following information):

Should not be dependent of OS/Browser/Version

Additional context This change will affect a lot of keywords and should be tested thoroughly Global search in the repo with regex @decorators.timeout_decorator\n yields 69 in results in 12 files

Kw GoTo has further specialized arg handling which should be addressed as a separate issue even though it is done in the same method which causes this issue QWeb.internal.decorators._equal_sign_handler

Also kw OpenBrowser does not allow using arguments url or browser_alias as named arguments As with GoTo this should be address as a separate issue, this one does not originate from _equal_sign_handler OpenBrowser https://duckduckgo.com browser_alias=chrome OpenBrowser url=https://duckduckgo.com browser_alias=chrome Keyword 'QWeb.Open Browser' got positional argument after named arguments.

tkoukkari commented 2 years ago

Yep, makes sense. Good catch.

turunenm commented 2 years ago

Closing issue as duplicate.

Refer to issue #65