'Getting error AttributeError: 'validateStore' object has no attribute 'driver'
I am trying to access driver from config.py file. I use fixture for opening browser. As I try to access driver in my test case class. I am getting error object has no attribute driver.
config.py
import pytest
from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait from webdriver_manager.chrome import ChromeDriverManager
@pytest.fixture(scope="class") def setup(request):
driver = webdriver.Chrome(executable_path=ChromeDriverManager().install())
wait=WebDriverWait(driver,10)
driver.get("https://automationteststore.com/")
driver.maximize_window()
request.cls.driver=driver
request.cls.wait=wait
yield
driver.close()
test Case
import pytest
from selenium import webdriver
@pytest.mark.usefixtures("setup") class validateStore():
def test_validateStorePage(self):
url=self.driver.current_url
print(url)
store=validateStore() store.test_validateStorePage()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
