Skip to content

Commit a8c30d9

Browse files
committed
Prevent PytestDeprecationWarning
1 parent 60bed14 commit a8c30d9

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def test_anything(self):
2626
import logging
2727
import math
2828
import os
29-
import pytest
3029
import re
3130
import sys
3231
import time
@@ -3185,13 +3184,21 @@ def __insert_test_result(self, state, err):
31853184

31863185
def __add_pytest_html_extra(self):
31873186
try:
3188-
pytest_html = pytest.config.pluginmanager.getplugin('html')
3189-
if self.with_selenium and pytest_html:
3190-
driver = self.driver
3191-
extra_url = pytest_html.extras.url(driver.current_url)
3192-
screenshot = driver.get_screenshot_as_base64()
3193-
extra_image = pytest_html.extras.image(screenshot,
3194-
name='Screenshot')
3187+
if self.with_selenium:
3188+
if not self.__last_page_screenshot:
3189+
self.__set_last_page_screenshot()
3190+
extra_url = {}
3191+
extra_url['name'] = 'URL'
3192+
extra_url['format'] = 'url'
3193+
extra_url['content'] = self.get_current_url()
3194+
extra_url['mime_type'] = None
3195+
extra_url['extension'] = None
3196+
extra_image = {}
3197+
extra_image['name'] = 'Screenshot'
3198+
extra_image['format'] = 'image'
3199+
extra_image['content'] = self.__last_page_screenshot
3200+
extra_image['mime_type'] = 'image/png'
3201+
extra_image['extension'] = 'png'
31953202
self._html_report_extra.append(extra_url)
31963203
self._html_report_extra.append(extra_image)
31973204
except Exception:

0 commit comments

Comments
 (0)