2021-05-01 14:49:59 -06:00
|
|
|
import pytest
|
|
|
|
from _pytest.fixtures import FixtureRequest
|
2021-12-15 21:53:41 -07:00
|
|
|
import undetected_chromedriver as uc
|
2021-05-01 14:49:59 -06:00
|
|
|
|
|
|
|
FAILED_SCREENSHOT_NAME = "failed.png"
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def head_uc(request: FixtureRequest):
|
|
|
|
request.instance.driver = uc.Chrome()
|
|
|
|
|
|
|
|
def teardown():
|
|
|
|
request.instance.driver.save_screenshot(FAILED_SCREENSHOT_NAME)
|
|
|
|
request.instance.driver.quit()
|
|
|
|
|
|
|
|
request.addfinalizer(teardown)
|
|
|
|
|
|
|
|
return request.instance.driver
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def headless_uc(request: FixtureRequest):
|
|
|
|
options = uc.ChromeOptions()
|
|
|
|
options.headless = True
|
|
|
|
request.instance.driver = uc.Chrome(options=options)
|
|
|
|
|
|
|
|
def teardown():
|
|
|
|
request.instance.driver.sapipve_screenshot(FAILED_SCREENSHOT_NAME)
|
|
|
|
request.instance.driver.quit()
|
|
|
|
|
|
|
|
request.addfinalizer(teardown)
|
|
|
|
|
|
|
|
return request.instance.driver
|
|
|
|
|
|
|
|
|
|
|
|
pytest.main()
|