I am trying to learn python and selenium. and I am using pytest-bdd. and there is conftest.py. Normally I defined my driver in this page under before_scenarios method. And I have basepage which contains click,hover_to,text_presents etc some operations. Conftest also use my BasePage click method to close popups. and I have LoginTest.py which use Basepage. How can I use driver for all pages. because I cant get driver. What is my mistake also could u pls explain? Here is my code: conftest.py:
bp = BasePage.BasePage()
def pytest_bdd_before_scenario():
global driver
url="myurl"
logger.info("\nBrowser operations before test running\n")
driver = webdriver.Chrome()
driver.get(url)
driver.maximize_window()
website_is_up_and_running(url)
bp.click((By.XPATH , "//div[@title='Kapat']"))
bp.click((By.XPATH , "//a[@class='close-button']"))
Here is my BasePage:
class BasePage():
def click(self,driver,by_locator):
WebDriverWait(driver, 60) .until(EC.visibility_of_element_located((by_locator))).click()
And Finally, this is my LoginTest.py:
import utilities.BasePage as BasePage
bp = BasePage.BasePage()
@when('I click the Login Button')
def i_click_the_login_button():
bp.hover_to_and_click(driver,(By.XPATH , "(//p[@class='link-text'])[1]")) //in this line I can't get driver.