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

fixed type hinting so that it is not converted to str #1866

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions atest/acceptance/keywords/async_javascript.robot
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Execute Async Javascript With ARGUMENTS and JAVASCRIPT Marker
... alert(arguments[0]);
Alert Should Be Present 123 timeout=10 s

Execute Javascript with dictionary object
&{ARGS}= Create Dictionary key=value number=${1} boolean=${TRUE}
${returned} Execute Async Javascript arguments[1](arguments[0]); ARGUMENTS ${ARGS}
Should Be True type($returned) == dict
Should Be Equal ${returned}[key] value
Should Be Equal ${returned}[number] ${1}
Should Be Equal ${returned}[boolean] ${TRUE}

Should Be Able To Return Javascript Primitives From Async Scripts Neither None Nor Undefined
${result} = Execute Async Javascript arguments[arguments.length - 1](123);
Should Be Equal ${result} ${123}
Expand Down
8 changes: 8 additions & 0 deletions atest/acceptance/keywords/javascript.robot
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ Execute Javascript from File With ARGUMENTS Marker
... 123
Alert Should Be Present 123 timeout=10 s

Execute Javascript with dictionary object
&{ARGS}= Create Dictionary key=value number=${1} boolean=${TRUE}
${returned} Execute JavaScript return arguments[0] ARGUMENTS ${ARGS}
Should Be True type($returned) == dict
Should Be Equal ${returned}[key] value
Should Be Equal ${returned}[number] ${1}
Should Be Equal ${returned}[boolean] ${TRUE}

Open Context Menu
[Tags] Known Issue Safari
Go To Page "javascript/context_menu.html"
Expand Down
4 changes: 2 additions & 2 deletions src/SeleniumLibrary/keywords/javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class JavaScriptKeywords(LibraryComponent):
arg_marker = "ARGUMENTS"

@keyword
def execute_javascript(self, *code: Union[WebElement, str]) -> Any:
def execute_javascript(self, *code: Any) -> Any:
"""Executes the given JavaScript code with possible arguments.

``code`` may be divided into multiple cells in the test data and
Expand Down Expand Up @@ -73,7 +73,7 @@ def execute_javascript(self, *code: Union[WebElement, str]) -> Any:
return self.driver.execute_script(js_code, *js_args)

@keyword
def execute_async_javascript(self, *code: Union[WebElement, str]) -> Any:
def execute_async_javascript(self, *code: Any) -> Any:
"""Executes asynchronous JavaScript code with possible arguments.

Similar to `Execute Javascript` except that scripts executed with
Expand Down