Skip to content

Commit 1aa3d16

Browse files
committed
fixed type hinting so that it is not converted to str
Signed-off-by: René <[email protected]>
1 parent 7dd3766 commit 1aa3d16

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

atest/acceptance/keywords/async_javascript.robot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ Execute Async Javascript With ARGUMENTS and JAVASCRIPT Marker
1919
... alert(arguments[0]);
2020
Alert Should Be Present 123 timeout=10 s
2121

22+
Execute Javascript with dictionary object
23+
&{ARGS}= Create Dictionary key=value number=${1} boolean=${TRUE}
24+
${returned} Execute Async Javascript arguments[1](arguments[0]); ARGUMENTS ${ARGS}
25+
Should Be True type($returned) == dict
26+
Should Be Equal ${returned}[key] value
27+
Should Be Equal ${returned}[number] ${1}
28+
Should Be Equal ${returned}[boolean] ${TRUE}
29+
2230
Should Be Able To Return Javascript Primitives From Async Scripts Neither None Nor Undefined
2331
${result} = Execute Async Javascript arguments[arguments.length - 1](123);
2432
Should Be Equal ${result} ${123}

atest/acceptance/keywords/javascript.robot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ Execute Javascript from File With ARGUMENTS Marker
8585
... 123
8686
Alert Should Be Present 123 timeout=10 s
8787

88+
Execute Javascript with dictionary object
89+
&{ARGS}= Create Dictionary key=value number=${1} boolean=${TRUE}
90+
${returned} Execute JavaScript return arguments[0] ARGUMENTS ${ARGS}
91+
Should Be True type($returned) == dict
92+
Should Be Equal ${returned}[key] value
93+
Should Be Equal ${returned}[number] ${1}
94+
Should Be Equal ${returned}[boolean] ${TRUE}
95+
8896
Open Context Menu
8997
[Tags] Known Issue Safari
9098
Go To Page "javascript/context_menu.html"

src/SeleniumLibrary/keywords/javascript.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class JavaScriptKeywords(LibraryComponent):
3030
arg_marker = "ARGUMENTS"
3131

3232
@keyword
33-
def execute_javascript(self, *code: Union[WebElement, str]) -> Any:
33+
def execute_javascript(self, *code: Any) -> Any:
3434
"""Executes the given JavaScript code with possible arguments.
3535
3636
``code`` may be divided into multiple cells in the test data and
@@ -73,7 +73,7 @@ def execute_javascript(self, *code: Union[WebElement, str]) -> Any:
7373
return self.driver.execute_script(js_code, *js_args)
7474

7575
@keyword
76-
def execute_async_javascript(self, *code: Union[WebElement, str]) -> Any:
76+
def execute_async_javascript(self, *code: Any) -> Any:
7777
"""Executes asynchronous JavaScript code with possible arguments.
7878
7979
Similar to `Execute Javascript` except that scripts executed with

0 commit comments

Comments
 (0)