-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconftest.py
34 lines (24 loc) · 1.03 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromiumService
from selenium.webdriver.firefox.service import Service as FFService
from selenium.webdriver.firefox.options import Options as FFOptions
def pytest_addoption(parser):
parser.addoption("--browser", action="store", default="chrome")
parser.addoption("--url", action="store", default="http://192.168.8.169:8081")
@pytest.fixture()
def browser(request):
browser_name = request.config.getoption("--browser")
url = request.config.getoption("--url")
if browser_name == "chrome":
driver = webdriver.Chrome(service=ChromiumService())
elif browser_name == "firefox":
# service = FFService(executable_path="/snap/bin/geckodriver") Для ubuntu 22.04
driver = webdriver.Firefox(options=FFOptions(), service=FFService())
else:
driver = webdriver.Safari()
driver.maximize_window()
request.addfinalizer(driver.close)
driver.get(url)
driver.url = url
return driver