Hi,
I've added a new fixture to return webdriver and access it within my 'Login' method. I'm receiving the below error as webdriver is not returned, instead a funtion object is returned.
Can someone please help with the best practices to add fixtures?
My end goal is : To add fixtures to conftest.py and access chrome/firefox driver for every login method in each case
test.py
I've added a new fixture to return webdriver and access it within my 'Login' method. I'm receiving the below error as webdriver is not returned, instead a funtion object is returned.
Can someone please help with the best practices to add fixtures?
My end goal is : To add fixtures to conftest.py and access chrome/firefox driver for every login method in each case
test.py
import pytest
from selenium import webdriver
from utilities.settings import url
from pageObjects.Login import Login
@pytest.fixture
def driverChrome():
driver = webdriver.Chrome()
return driver
Login(driverChrome).loginToApp()
Login(driverChrome).setLoginValues()Login.pyfrom utilities.settings import url, username, password, company_code
import pytest
class Login:
textbox_username_id = "usercode"
textbox_password_id = "mirror_password"
textbox_companyCode_id = "companyCode"
btn_login_xpath = "//input[@value='Login']"
def __init__(self, driver1):
self.driver1 = driver1
def loginToApp(self):
self.driver1.get(url)
self.driver1.maximize_window()
def setLoginValues(self):
self.driver1.find_element("id", self.textbox_username_id).send_keys(username)
self.driver1.find_element("id", self.textbox_password_id).send_keys(password)
self.driver1.find_element("id", self.textbox_companyCode_id).send_keys(company_code)
self.driver1.find_element("xpath", self.btn_login_xpath).click()
self.driver1.save_screenshot(".\\screenshots\\"+"setLoginValues.png")Error:Error:Traceback (most recent call last):
File "C:\Users\Nikita\PycharmProjects\thymeit_auto_base\testCases\test.py", line 15, in <module>
Login(driverChrome).loginToApp()
File "C:\Users\Nikita\PycharmProjects\thymeit_auto_base\pageObjects\Login.py", line 15, in loginToApp
self.driver1.get(url)
^^^^^^^^^^^^^^^^
AttributeError: 'function' object has no attribute 'get'
