如何解决 NoneType' 对象没有属性 'get'
how to resolve NoneType' object has no attribute 'get'
虽然 运行 下面的代码出现错误“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()
确保您的 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()
虽然 运行 下面的代码出现错误“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()
确保您的 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()