运行以下 PyUnit 测试:
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 是一个库模块,其中包含要在 iOS 设备上的此单元测试上运行的 setUp。设置看起来像这样:
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 的 selenium 工作代码:
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)