11from PuppeteerLibrary .base .librarycomponent import LibraryComponent
22from PuppeteerLibrary .base .robotlibcore import keyword
33from PuppeteerLibrary .ikeywords .ibrowsermanagement_async import iBrowserManagementAsync
4+ from robot .libraries .BuiltIn import BuiltIn
45
56
67class BrowserManagementKeywords (LibraryComponent ):
@@ -18,8 +19,9 @@ def open_browser(self, url, browser="chrome", alias=None, options={}):
1819 The ``browser`` argument specifies which browser to use.
1920
2021 | = Browser = | = Name(s) = | = Engine = |
21- | Google Chrome | chrome | Puppeteer |
22+ | Google Chrome Default | chrome | Playwright |
2223 | Google Chrome Playwright | pwchrome | Playwright |
24+ | Google Chrome Puppeteer | ptchrome | Puppeteer |
2325 | Webkit (Safari engine) | webkit | Playwright |
2426 | Firefox | firefox | Playwright |
2527
@@ -162,6 +164,30 @@ def enable_emulate_mode(self, emulate_name):
162164 """
163165 return self .loop .run_until_complete (self .get_async_keyword_group ().enable_emulate_mode_async (emulate_name ))
164166
167+ ##############################
168+ # Trace
169+ ##############################
170+ @keyword
171+ def start_tracing (self ):
172+ """Create trace log file
173+
174+ # View the trace by running following command
175+
176+ playwright show-trace trace.zip
177+ """
178+ return self .loop .run_until_complete (self .get_async_keyword_group ().start_tracing ())
179+
180+ @keyword
181+ def stop_tracing (self , path = None ):
182+ """Stop trace and generate the trace file.
183+
184+ Default will be ``traces/<testcasename>.zip``
185+ """
186+ if path is None :
187+ test_name = BuiltIn ().get_variable_value ("${TEST_NAME}" )
188+ path = 'traces/' + test_name + '.zip'
189+ return self .loop .run_until_complete (self .get_async_keyword_group ().stop_tracing (path ))
190+
165191 ##############################
166192 # Page
167193 ##############################
0 commit comments