Page對象框架運行以下的PyUnit測試:類型錯誤: 'NoneType' 對象不是可迭代,使用硒/ Appium
import unittest #imports unit test/ability to run as pyunit test
from page_objects.webdriver_wrapper import webdriver_wrapper
from page_objects.home import home
from page_objects.inbook import inbook
from page_objects.myebooks import myebooks
from page_objects.login import login
import time
class regression(unittest.TestCase):
def regression(self, webd_wrap):
page_login = login(webd_wrap)
page_login.secure_login()
def test_regression(self): #running x as a unit test
for browser in webdriver_wrapper().setUp():
self.regression(webdriver_wrapper(browser))
print "Module Complete", __name__
if __name__ == "__main__":
unittest.main()
我收到以下錯誤:
ERROR: test_regression (mobile_testing.regression_test.regression)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Zola/Documents/workspace/com.zolamobile.eviltest/mobile_testing/regression_test.py", line 24, in test_regression
for setUp in webdriver_wrapper().setUp():
TypeError: 'NoneType' object is not iterable
webdriver_wrapper是一個庫模塊,包含setUp以在iOS設備上的unittest上運行。設置是這樣的:
def setUp(self):
# set up appium
success = True
app = "com.zolabooks.zolareader"
app = os.path.abspath(app)
self.driver = webdriver.Remote(
command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities={
'browserName': 'iOS',
'platform': 'Mac',
'version': '6.1',
'ipa': app
})
self._values = []
我試圖讓這個使用頁面對象模型框架的工作,使在頁面上的元素可以被抽象。
編輯:使用硒的瀏覽器,而不是iOS的這是工作代碼:
def test_addtolist_notsignedin_modal(self): #running x as a unit test
for browser in webdriver_wrapper._browsers:
self.add_to_list_notsignedin_modal_test(webdriver_wrapper(browser))
凡_browsers被定義爲:
_browsers = ["chrome", "firefox"]
def open_chrome(self):
self._driver = webdriver.Chrome('/Users/Jay/Downloads/chromedriver')
self._driver.implicitly_wait(10)
self.wait = WebDriverWait(self._driver, 10)
def open_firefox(self):
self._driver = webdriver.Firefox()
self._driver.implicitly_wait(10)
self.wait = WebDriverWait(self._driver, 10)
是不是應該設置返回的東西? – hivert