-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
49 lines (43 loc) · 2.21 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import IEDriverManager
#Bu fonksiyon cmd üzerinde --browser parametresi ile browser seçme imkanı sağlar.
#Eğer herhangi bir parametre girilmez ise default olarak ilk browser ile çalışır.
def pytest_addoption(parser):
parser.addoption("--browser", action="store", default="chrome", help="Type in browser e.g. chrome or firefox")
#login_test sayfasındaki driver bilgisi bu fonksiyon ile gönderilir.
@pytest.fixture(scope="class")
def test_setup(request):
from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FireFoxOptions
from selenium.webdriver.chrome.options import Options as ChromeOptions
#--browser parametresi boş bırakılırsa default olarak Chrome ile çalışır.
browser = request.config.getoption("--browser")
if browser == 'explorer':
caps = webdriver.DesiredCapabilities.INTERNETEXPLORER
caps["ignoreProtectedModeSettings"] = True
iepath = "D:/SSO/Lirex-Solvay/WebdriverManagerTest/drivers/IEDriverServer.exe"
driver = webdriver.Ie(executable_path=iepath, desired_capabilities=caps)
#driver = webdriver.Chrome(ChromeDriverManager().install())
#driver = webdriver.Ie(IEDriverManager().install())
elif browser == 'firefox':
fpath = "D:/SSO/Lirex-Solvay/WebdriverManagerTest/drivers/geckodriver.exe"
#options = FireFoxOptions()
#options.headless = True
driver = webdriver.Firefox(executable_path=fpath)
#driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
else:
cpath = "D:/SSO/Lirex-Solvay/WebdriverManagerTest/drivers/chromedriver.exe"
#chrome_options = ChromeOptions()
#chrome_options.add_argument("--headless")
driver = webdriver.Chrome(executable_path= cpath)
#driver = webdriver.Ie(IEDriverManager().install())
#driver = webdriver.Chrome(ChromeDriverManager().install())
driver.implicitly_wait(10)
driver.maximize_window()
request.cls.driver = driver
yield
driver.close()
driver.quit()
print("Test Completed!")