-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fixture3.py
More file actions
24 lines (20 loc) · 842 Bytes
/
Copy pathtest_fixture3.py
File metadata and controls
24 lines (20 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By
LINK = "http://selenium1py.pythonanywhere.com/"
@pytest.fixture
def browser():
print('\nstart browser for test ...')
browser = webdriver.Chrome()
yield browser
# этот код выполнится после завершения теста
print('\nquit browser ...')
browser.quit()
class TestMainPage:
# вызываем фикстуру в тесте, передав ее как параметр
def test_guest_should_see_login_link(self, browser):
browser.get(LINK)
browser.find_element(By.CSS_SELECTOR, "#login_link")
def test_guest_should_see_basket_link_on_the_main_page(self, browser):
browser.get(LINK)
browser.find_element(By.CSS_SELECTOR, ".basket-mini .btn-group > a")