運行以下代碼時出現錯誤“NoneType'物件沒有屬性'get'”
TestProductRecogic.py:
import unittest
from PageObject.ProductRcognic import ProductPage
import pytest
class TestProductRecognic(unittest.TestCase):
@pytest.fixture(autouse=True)
def classSetup(self, setup):
self.driver = setup
def test_Product(self):
self.driver.get("https://www.recognic.ai/")
self.ep = ProductPage(self.driver)
self.ep.clickOnProduct()
def tearDown(self):
self.driver.close()
uj5u.com熱心網友回復:
確保您setup正在回傳驅動程式實體。
您需要有一個看起來像這樣的設定夾具:
@pytest.fixture()
def setup():
driver = webdriver.Chrome(path) #example
return driver
class TestProductRecognic(unittest.TestCase):
@pytest.fixture(autouse=True)
def classSetup(self, setup):
self.driver = setup
def test_Product(self):
self.driver.get("https://www.recognic.ai/")
self.ep = ProductPage(self.driver)
self.ep.clickOnProduct()
def tearDown(self):
self.driver.close()
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/482273.html
