Skip to content

Commit 9f0b4c1

Browse files
committed
Support puppeteer capture screenshot
1 parent 8d8abec commit 9f0b4c1

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

ExcelDataDriver/__init__.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ def _is_same_keyword(self, first, second):
266266
def _capture_screenshot(self):
267267
try:
268268
# Capture selenium screenshot
269-
custom_selenium = CustomSelenium()
270269
today = datetime.now()
271270
date_and_time = today.strftime("%Y%m%d%H%M%S")
272271
screenshot_name = date_and_time + '_' + str(self.screenshot_running_id) + '.png'
@@ -275,10 +274,24 @@ def _capture_screenshot(self):
275274
os.makedirs('./' + ExcelDataDriver.REPORT_PATH + '/screenshots/')
276275
except:
277276
None
277+
278+
# Capture screenshot by selenium
279+
is_capture_success = False
278280
try:
281+
custom_selenium = CustomSelenium()
279282
custom_selenium.capture_full_page_screenshot('./'+ExcelDataDriver.REPORT_PATH+'/screenshots/'+screenshot_name)
283+
is_capture_success = True
280284
except Exception as e:
281-
return str(e)
285+
is_capture_success = False
286+
287+
# Capture screenshot by puppeteer
288+
if is_capture_success is False:
289+
try:
290+
library = BuiltIn().get_library_instance('PuppeteerLibrary')
291+
library.capture_page_screenshot('./'+ExcelDataDriver.REPORT_PATH+'/screenshots/'+screenshot_name, True)
292+
except Exception as e:
293+
return e
294+
282295
return '=HYPERLINK(".//screenshots//' + screenshot_name + '","' + screenshot_name + '")'
283296
except:
284297
return None

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ inject==3.3.2
22
openpyxl==3.0.5
33
Pillow>=6.2.1
44
robotframework-seleniumlibrary==4.1.0
5+
robotframework-puppeteerlibrary

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
'setuptools==41.0.1',
4545
'Pillow>=6.2.1',
4646
'robotframework-seleniumlibrary',
47+
'robotframework-puppeteerlibrary',
4748
],
4849
python_requires='>3.5',
4950
test_suite='nose.collector',

0 commit comments

Comments
 (0)