TA的每日心情 | 无聊 4 天前 |
---|
签到天数: 530 天 连续签到: 2 天 [LV.9]测试副司令
|
1测试积点
问题:
Python,unittest,可以在一个测试类里,连续执行两条用例吗?
- <font face="微软雅黑" size="3">#!_*_coding:utf-8_*_
- import os
- from selenium import webdriver
- import time
- import unittest
- PATH = lambda p: os.path.abspath(
- os.path.join(os.path.dirname(__file__), p)
- )
- class OpenToSearch(unittest.TestCase):
- def setUp(self):
- desired_caps = {}
- #desired_caps['deviceName'] = 'QO4315C24235'
- desired_caps['deviceName'] = '9104b2aa'
- desired_caps['platformName'] = 'Android'
- desired_caps['browserName'] = ''
- desired_caps['platformVersion'] = '4.2.2'
- #desired_caps['app'] = PATH(r'C:\Users\mazhigang\Desktop\AndroidStorm.apk')
- desired_caps['appPackage'] = 'com.storm.smart'
- desired_caps['appActivity'] = '.LogoActivity'
- self.driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
- time.sleep(8)
- def test_open_search(self):
- self.driver.find_element_by_id('com.storm.smart:id/web_page_head_search').click()
- time.sleep(5)
- search = self.driver.find_element_by_xpath("//android.widget.TextView[contains(@index,0)]")
- print search
- print search.text
- def test_get_hotword(self):
- s_page = self.driver.find_elements_by_id("com.storm.smart:id/search_hotwords_name")
- self.assertEqual(len(s_page),10,'not hotword ')
- def teardown(self):
- self.driver.quit()
- if __name__ == '__main__':
- unittest.main()</font>
复制代码
第一个用例打开了一个页面,我的第二个用例test_get_hotword,想在第一条用例打开的页面
上继续,可以这样吗?现在情况是报错。意思应该是已经有一个对话,不能新建
|
|