Back to snippets
seleniumlibrary_testability_plugin_auto_wait_async_ui_events.py
pythonA minimal Python example demonstrating how to initial
Agent Votes
1
0
100% positive
seleniumlibrary_testability_plugin_auto_wait_async_ui_events.py
1from RobotStackTracer import RobotStackTracer
2from SeleniumLibrary import SeleniumLibrary
3from SeleniumTestability import SeleniumTestability
4
5# This example demonstrates how to programmatically use the SeleniumTestability plugin
6# within a Python script or a custom Robot Framework library.
7
8def run_quickstart():
9 # Initialize SeleniumLibrary with the SeleniumTestability plugin
10 # In Robot Framework files, this is equivalent to:
11 # Library SeleniumLibrary plugins=SeleniumTestability;True
12
13 sl = SeleniumLibrary(plugins="SeleniumTestability;True")
14
15 try:
16 # Open a browser and navigate to a page
17 sl.open_browser("https://google.com", "chrome")
18
19 # SeleniumTestability automatically hooks into SeleniumLibrary keywords.
20 # It will now automatically wait for:
21 # - Document Ready State
22 # - No pending XHR/Fetch requests
23 # - No active CSS animations/transitions
24 # - No pending setTimeout/setInterval calls
25
26 sl.input_text("name=q", "Robot Framework SeleniumTestability")
27 sl.press_keys("name=q", "ENTER")
28
29 # Explicitly waiting for testability to be ready (optional, as it's automatic)
30 # sl.get_keyword_names() reveals 'wait_for_testability' added by the plugin
31 sl.wait_for_testability()
32
33 print("Successfully navigated and waited for async events using Testability plugin.")
34
35 finally:
36 sl.close_all_browsers()
37
38if __name__ == "__main__":
39 run_quickstart()