1
1
from PuppeteerLibrary .base .librarycomponent import LibraryComponent
2
2
from PuppeteerLibrary .base .robotlibcore import keyword
3
3
from PuppeteerLibrary .ikeywords .ibrowsermanagement_async import iBrowserManagementAsync
4
+ from robot .libraries .BuiltIn import BuiltIn
4
5
5
6
6
7
class BrowserManagementKeywords (LibraryComponent ):
@@ -18,8 +19,9 @@ def open_browser(self, url, browser="chrome", alias=None, options={}):
18
19
The ``browser`` argument specifies which browser to use.
19
20
20
21
| = Browser = | = Name(s) = | = Engine = |
21
- | Google Chrome | chrome | Puppeteer |
22
+ | Google Chrome Default | chrome | Playwright |
22
23
| Google Chrome Playwright | pwchrome | Playwright |
24
+ | Google Chrome Puppeteer | ptchrome | Puppeteer |
23
25
| Webkit (Safari engine) | webkit | Playwright |
24
26
| Firefox | firefox | Playwright |
25
27
@@ -162,6 +164,30 @@ def enable_emulate_mode(self, emulate_name):
162
164
"""
163
165
return self .loop .run_until_complete (self .get_async_keyword_group ().enable_emulate_mode_async (emulate_name ))
164
166
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
+
165
191
##############################
166
192
# Page
167
193
##############################
0 commit comments