Skip to content

Commit 8ab1b31

Browse files
Vincenzo Gasparoaaltat
authored andcommitted
execute_javascript code type changed to Union
1 parent 104bc60 commit 8ab1b31

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

atest/acceptance/keywords/javascript.robot

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ Execute Javascript With ARGUMENTS Marker Only
6161
... 0987
6262
Alert Should Be Present 123 timeout=10 s
6363

64+
Execute Javascript With ARGUMENTS Marker And WebElement
65+
[Documentation]
66+
... Checks if the body (WebElement)
67+
... is parsed correctly as script argument
68+
... then compare its tagName to 'body'
69+
${body_webelement} Get WebElement css:body
70+
${tag_name} Execute Javascript
71+
... return arguments[0].tagName;
72+
... ARGUMENTS
73+
... ${body_webelement}
74+
Should Be Equal As Strings ${tag_name} body ignore_case=True
75+
6476
Execute Javascript from File
6577
[Documentation]
6678
... LOG 2:1 REGEXP: Reading JavaScript from file .*executed_by_execute_javascript.*

src/SeleniumLibrary/keywords/javascript.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616

1717
import os
1818
from collections import namedtuple
19-
from typing import Any
19+
from typing import Any, Union
2020

2121
from robot.utils import plural_or_not, seq2str
2222

23+
from selenium.webdriver.remote.webelement import WebElement
2324
from SeleniumLibrary.base import LibraryComponent, keyword
2425

2526

@@ -29,7 +30,7 @@ class JavaScriptKeywords(LibraryComponent):
2930
arg_marker = "ARGUMENTS"
3031

3132
@keyword
32-
def execute_javascript(self, *code: str) -> Any:
33+
def execute_javascript(self, *code: Union[WebElement, str]) -> Any:
3334
"""Executes the given JavaScript code with possible arguments.
3435
3536
``code`` may be divided into multiple cells in the test data and

0 commit comments

Comments
 (0)