|
@@ -1,8 +1,10 @@
|
|
import datetime
|
|
import datetime
|
|
import os
|
|
import os
|
|
|
|
+from typing import Callable, Generator
|
|
|
|
|
|
import icecream
|
|
import icecream
|
|
import pytest
|
|
import pytest
|
|
|
|
+from selenium import webdriver
|
|
|
|
|
|
from .user import User
|
|
from .user import User
|
|
|
|
|
|
@@ -10,7 +12,7 @@ icecream.install()
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
@pytest.fixture
|
|
-def chrome_options(chrome_options):
|
|
|
|
|
|
+def chrome_options(chrome_options: webdriver.ChromeOptions) -> webdriver.ChromeOptions:
|
|
chrome_options.add_argument('headless')
|
|
chrome_options.add_argument('headless')
|
|
chrome_options.add_argument('disable-gpu')
|
|
chrome_options.add_argument('disable-gpu')
|
|
chrome_options.add_argument('window-size=1200x600')
|
|
chrome_options.add_argument('window-size=1200x600')
|
|
@@ -19,23 +21,23 @@ def chrome_options(chrome_options):
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
@pytest.fixture
|
|
-def selenium(selenium):
|
|
|
|
|
|
+def selenium(selenium: webdriver.Chrome) -> webdriver.Chrome:
|
|
selenium.implicitly_wait(0.1)
|
|
selenium.implicitly_wait(0.1)
|
|
selenium.set_page_load_timeout(1)
|
|
selenium.set_page_load_timeout(1)
|
|
return selenium
|
|
return selenium
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
@pytest.fixture()
|
|
-def user(selenium):
|
|
|
|
|
|
+def user(selenium: webdriver.Chrome) -> Generator[User, None, None]:
|
|
user = User(selenium)
|
|
user = User(selenium)
|
|
yield user
|
|
yield user
|
|
user.stop_server()
|
|
user.stop_server()
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
@pytest.fixture
|
|
-def screenshot(selenium):
|
|
|
|
|
|
+def screenshot(selenium: webdriver.Chrome) -> Callable[[str], None]:
|
|
# original taken from https://github.com/theserverlessway/pytest-chrome/blob/master/tests/conftest.py
|
|
# original taken from https://github.com/theserverlessway/pytest-chrome/blob/master/tests/conftest.py
|
|
- def shot(name=''):
|
|
|
|
|
|
+ def shot(name: str = '') -> None:
|
|
directory = 'screenshots'
|
|
directory = 'screenshots'
|
|
if not os.path.exists(directory):
|
|
if not os.path.exists(directory):
|
|
os.makedirs(directory)
|
|
os.makedirs(directory)
|