Skip to content

Commit 2615412

Browse files
emanloveaaltat
authored andcommitted
Added --event-firing-webdriver argument to test runner
An example of invoking the event firing webdriver, python atest\run.py --nounit --event-firing-webdriver firefox --suite=selenium_move_to_workaround
1 parent 82604be commit 2615412

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

atest/acceptance/2-event_firing_webdriver/selenium_move_to_workaround.robot

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
*** Settings ***
22
Documentation Can be deleted when minimum Selenium version 4.0
3-
Library SeleniumLibrary event_firing_webdriver=${CURDIR}/MyListener.py
3+
Library SeleniumLibrary event_firing_webdriver=${event_firing_or_none}
44
Resource resource_event_firing_webdriver.robot
55
Force Tags NoGrid
66
Suite Setup Open Browser ${FRONT PAGE} ${BROWSER} alias=event_firing_webdriver
77
... remote_url=${REMOTE_URL} desired_capabilities=${DESIRED_CAPABILITIES}
8+
Suite Teardown Close All Browsers
9+
10+
*** Variables ***
11+
${event_firing_or_none} ${NONE}
812

913
*** Test Cases ***
1014
Selenium move_to workaround Click Element At Coordinates
@@ -16,7 +20,7 @@ Selenium move_to workaround Scroll Element Into View
1620
Scroll Element Into View id:some_id
1721

1822
Selenium move_to workaround Mouse Out
19-
[Documentation] LOG 1:8 DEBUG Workaround for Selenium 3 bug.
23+
[Documentation] LOG 1:5 DEBUG Workaround for Selenium 3 bug.
2024
Mouse Out id:some_id
2125

2226
Selenium move_to workaround Mouse Over
@@ -40,7 +44,7 @@ Click Element Action Chain
4044
[Tags] NoGrid
4145
[Documentation]
4246
... LOB 1:1 INFO Clicking 'singleClickButton' using an action chain.
43-
... LOG 2:5 DEBUG GLOB: *actions {"actions": [{*
47+
... LOG 2:6 DEBUG GLOB: *actions {"actions": [{*
4448
[Setup] Initialize Page For Click Element
4549
Click Element singleClickButton action_chain=True
4650
Element Text Should Be output single clicked

atest/run.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
SRC_DIR = os.path.normpath(os.path.join(ROOT_DIR, os.pardir, "src"))
7575
TEST_LIBS_DIR = os.path.join(RESOURCES_DIR, "testlibs")
7676
HTTP_SERVER_FILE = os.path.join(RESOURCES_DIR, "testserver", "testserver.py")
77+
EVENT_FIRING_LISTENER = os.path.join(RESOURCES_DIR, "testlibs", "MyListener.py")
7778

7879
ROBOT_OPTIONS = [
7980
"--doc",
@@ -101,14 +102,14 @@
101102
]
102103

103104

104-
def acceptance_tests(interpreter, browser, rf_options=None, grid=None):
105+
def acceptance_tests(interpreter, browser, rf_options=None, grid=None, event_firing=None):
105106
if os.path.exists(RESULTS_DIR):
106107
shutil.rmtree(RESULTS_DIR)
107108
os.mkdir(RESULTS_DIR)
108109
if grid:
109110
hub, node = start_grid()
110111
with http_server():
111-
execute_tests(interpreter, browser, rf_options, grid)
112+
execute_tests(interpreter, browser, rf_options, grid, event_firing)
112113
failures = process_output(browser)
113114
if failures:
114115
print(
@@ -191,7 +192,7 @@ def http_server():
191192
serverlog.close()
192193

193194

194-
def execute_tests(interpreter, browser, rf_options, grid):
195+
def execute_tests(interpreter, browser, rf_options, grid, event_firing):
195196
options = []
196197
if grid:
197198
runner = interpreter.split() + [
@@ -215,6 +216,11 @@ def execute_tests(interpreter, browser, rf_options, grid):
215216
]
216217
else:
217218
command += ["--exclude", "OnlyGrid"]
219+
if event_firing:
220+
command += [
221+
"--variable",
222+
f"event_firing_or_none:{EVENT_FIRING_LISTENER}",
223+
]
218224
command += options + [ACCEPTANCE_TEST_DIR]
219225
log_start(command)
220226
syslog = os.path.join(RESULTS_DIR, "syslog.txt")
@@ -296,18 +302,25 @@ def create_zip():
296302
default=False,
297303
action="store_true",
298304
)
305+
parser.add_argument(
306+
"--event-firing-webdriver",
307+
help="Run tests using event firing webdriver.",
308+
default=False,
309+
action="store_true",
310+
)
299311
args, rf_options = parser.parse_known_args()
300312
browser = args.browser.lower().strip()
301313
selenium_grid = is_truthy(args.grid)
302314
interpreter = args.interpreter
315+
event_firing_webdriver = args.event_firing_webdriver
303316
if args.nounit:
304317
print("Not running unit tests.")
305318
else:
306319
rc = subprocess.call([interpreter, UNIT_TEST_RUNNER])
307320
if rc != 0:
308321
print("Not running acceptance test, because unit tests failed.")
309322
sys.exit(rc)
310-
failures = acceptance_tests(interpreter, browser, rf_options, selenium_grid)
323+
failures = acceptance_tests(interpreter, browser, rf_options, selenium_grid, event_firing_webdriver)
311324
if args.zip:
312325
create_zip()
313326
sys.exit(failures)

0 commit comments

Comments
 (0)