Answer the question
In order to leave comments, you need to log in
Why does pytest open browser when running test 2==2?
Greetings.
I'm trying to test a website with pytest and selenium webdriver. In the main fixture, do I create and return a Browser object? in which there will be methods for working with tabs, browser, etc. The problem is that even in a simple test where 2 == 2 is checked, the browser opens.
conftest.py file
import pytest
from app.browser import Browser
@pytest.fixture(scope="session")
def browser(request):
# TODO add authorization check
app = Browser()
#request.addfinalizer(app.destroy)
return app
from selenium import webdriver
from config import *
class Browser:
def __init__(self):
if browser == "firefox":
self.browser = webdriver.Firefox()
elif browser == "chrome":
self.browser = webdriver.Chrome()
elif browser == "ie":
self.browser = webdriver.Ie()
self.browser.implicitly_wait(5)
def open_me(self):
self.browser.get('http://google.ru')
def destroy(self):
self.browser.quit()
def test_open_page(browser):
assert 2==2
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question