test_fixture10.py 822 B

1234567891011121314151617181920212223242526272829
  1. import pytest
  2. from selenium import webdriver
  3. link = "http://selenium1py.pythonanywhere.com/"
  4. @pytest.fixture(scope="function")
  5. def browser():
  6. print("\nstart browser for test..")
  7. browser = webdriver.Chrome()
  8. yield browser
  9. print("\nquit browser..")
  10. browser.quit()
  11. class TestMainPage1():
  12. def test_guest_should_see_login_link(self, browser):
  13. browser.get(link)
  14. browser.find_element_by_css_selector("#login_link")
  15. def test_guest_should_see_basket_link_on_the_main_page(self, browser):
  16. browser.get(link)
  17. browser.find_element_by_css_selector(".basket-mini .btn-group > a")
  18. @pytest.mark.xfail
  19. def test_guest_should_see_search_button_on_the_main_page(self, browser):
  20. browser.get(link)
  21. browser.find_element_by_css_selector("button.favorite")