#!_*_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()

第一个用例打开了一个页面,我的第二个用例 test_get_hotword,想在第一条用例打开的页面上继续,可以这样吗?现在情况是报错。意思应该是已经有一个对话,不能新建


↙↙↙阅读原文可查看相关链接,并与作者交流