Selenium Python PageObject

时间:2018-01-09 08:56:33

标签: python-3.x testing selenium-webdriver cross-platform pytest

我想知道如何在另一个类中传递conftest(pytest)的self.driver?

conftest.py

  def driver(request):
    self.driver = webdriver.Remote("xxxxx")
  def teardown():
    self.driver.quit()

TestSample.py

Class B():
  # How use self.driver ?????

2 个答案:

答案 0 :(得分:1)

你可以玩夹具

conftest.py

  def driver(request):
    self.driver = webdriver.Remote("xxxxx")
  def teardown():
    self.driver.quit()

TestSample.py

@pytest.mark.usefixtures("driver")
Class B():
  # How use self.driver ?????
  def test_sample(self, driver):
    tuto(driver)

Link explains

答案 1 :(得分:-2)

使用()继承b()类,然后使用super()访问超类a()

的self.driver