class YuxiChat(unittest.TestCase): def setUp(self): self.commontools = CommonTools() self.commontools.init_Driver() time.sleep(3) def tearDown(self): self.commontools.quit_Driver() def testChat(self): self.getPage() self.commontools.clickElement('com.yuxip:id/et_yx_text') time.sleep(2) for i in range(10): self.commontools.sendKeys('com.yuxip:id/et_yx_text', u'戏文') self.commontools.clickElement('com.yuxip:id/tv_text_send') time.sleep(0.5) def getPage(self): self.commontools.clickElement('com.yuxip:id/tb_chat') time.sleep(2) # 列表定位 try: self.commontools.clickListFindElements('com.yuxip:id/listView', 'android.widget.RelativeLayout', 0) except Exception, e: print e time.sleep(3)
class YuxiSearchDrama(unittest.TestCase): def setUp(self): self.commontools = CommonTools() self.commontools.init_Driver() sleep(2) def tearDown(self): self.commontools.quit_Driver() def test_searchDrama(self): self.commontools.waitForElement('com.yuxip:id/iv_top_left', 2) self.commontools.clickElement('com.yuxip:id/iv_top_left') print self.commontools.getCurrentActivity() self.commontools.clickElement('com.yuxip:id/ll_top_search') # print self.commontools.getCurrentActivity() self.assertEqual(self.commontools.getCurrentActivity(), '.ui.activity.other.StoryListSearchActivity') self.commontools.waitForElement('com.yuxip:id/tv_search', 2) data = u'xx' self.commontools.sendKeys('com.yuxip:id/edit_search', data) self.commontools.clickElement('com.yuxip:id/tv_search') sleep(2) try: if self.commontools.checkElementIsShown( 'android.support.v7.widget.RecyclerView'): print u'搜索成功' elif self.commontools.checkElementIsShown( 'com.yuxip:id/tv_search_note'): print u'搜索没结果' except Exception, e: print e
class YuxiLike(unittest.TestCase): def setUp(self): self.commontools = CommonTools() self.commontools.init_Driver() time.sleep(3) def tearDown(self): self.commontools.quit_Driver() def test_Like(self): # 定位到测试指定页面 try: self.commontools.clickElement('com.yuxip:id/tb_story') except Exception, e: print e # time.sleep(2) self.commontools.waitForElement('com.yuxip:id/linear_channelselect', 2) try: self.commontools.clickListFindElements( 'com.yuxip:id/linear_channelselect', 'com.yuxip:id/tv_item_channel_select', 4) except Exception, e: print e
class YuxiLogin(unittest.TestCase): def setUp(self): self.commontools = CommonTools() self.commontools.init_Driver() sleep(2) def tearDown(self): self.commontools.quit_Driver() def test_yuxiMbLogin(self): # print self.commontools.getCurrentActivity() if self.commontools.getCurrentActivity( ) == '.ui.activity.other.LoginMobileActivity': print u'处于登出状态: 进行登录操作' self.yuxi_MbLoginIn() else: print u'处于登录状态: 进行登出再登录操作' self.yuxi_LoginOut() self.yuxi_MbLoginIn() # 语戏手机登录 def yuxi_MbLoginIn(self): self.commontools.waitForElement('com.yuxip:id/iv_login_mobile', 2) self.commontools.clickElement('com.yuxip:id/iv_login_mobile') self.commontools.sendKeys('com.yuxip:id/et_login_name', '10000000008') sleep(2) self.commontools.sendKeys('com.yuxip:id/et_login_password', '123') # self.commontools.hideKeyBoard() self.commontools.clickElement('com.yuxip:id/tv_login_btn') sleep(2) try: if self.commontools.getCurrentActivity( ) != '.ui.activity.other.LoginMobileActivity': print u'登录成功' except Exception, e: print e