Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python selenium中所有页面的驱动程序对象_Python_Selenium_Pytest - Fatal编程技术网

如何使用python selenium中所有页面的驱动程序对象

如何使用python selenium中所有页面的驱动程序对象,python,selenium,pytest,Python,Selenium,Pytest,我正在努力学习python和selenium。我正在使用pytestbdd。还有conftest.py。通常情况下,我在本页中的before_scenarios方法下定义了我的驱动程序。我有一个包含点击、悬停、文本显示等操作的基本页面。Conftest还使用my BasePage单击方法关闭弹出窗口。我有LoginTest.py,它使用Basepage。 如何对所有页面使用驱动程序。因为我找不到司机。我的错误是什么?你能解释一下吗? 这是我的密码: conftest.py: bp = BaseP

我正在努力学习python和selenium。我正在使用pytestbdd。还有conftest.py。通常情况下,我在本页中的before_scenarios方法下定义了我的驱动程序。我有一个包含点击、悬停、文本显示等操作的基本页面。Conftest还使用my BasePage单击方法关闭弹出窗口。我有LoginTest.py,它使用Basepage。 如何对所有页面使用驱动程序。因为我找不到司机。我的错误是什么?你能解释一下吗? 这是我的密码: 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']"))
这是我的主页:

class BasePage():
 
  def click(self,driver,by_locator):
     WebDriverWait(driver, 60) .until(EC.visibility_of_element_located((by_locator))).click()
最后,这是我的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.