本文整理汇总了Python中common.py_common_keyword.CommonFunctions.CommonFunctions.run_test_case方法的典型用法代码示例。如果您正苦于以下问题:Python CommonFunctions.run_test_case方法的具体用法?Python CommonFunctions.run_test_case怎么用?Python CommonFunctions.run_test_case使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.py_common_keyword.CommonFunctions.CommonFunctions
的用法示例。
在下文中一共展示了CommonFunctions.run_test_case方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open_installed_app
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class open_installed_app():
def __init__(self):
self.common_fn = CommonFunctions()
def app_homePage(self):
try:
manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
if manage_buttons[4].text==u'管理':
manage_buttons[4].click()
time.sleep(2)
print u'go into manage page\n'
else:
print u'manageButton[4].text do not equal to 管理'
except:
print u'not find manage button\n'
def app_installedList(self):
try:
self.app_homePage()
installed_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
installed_buttons[2].click()
time.sleep(2)
try:
title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
if title.text==u'已安装':
print u'get installed apps list\n'
try:
appName = self.common_fn.wait_for_elements(r'com.tclmarket:id/name',By.ID)[5].text
click_apps=self.common_fn.wait_for_elements(r'com.tclmarket:id/fold_tag',By.ID)
click_apps[5].click()
open_button=self.common_fn.wait_for_element(r'com.tclmarket:id/bottom_action_left')
open_button.click()
print u'open app "%s" \n' % appName
self.common_fn.driver.keyevent('4')
return True
except Exception as e:
print u'not find apps\n'
s = sys.exc_info()
print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
else:
pass
except:
pass
except:
print u'fail to go into installed apps page\n'
s = sys.exc_info()
print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
def run(self):
start = startOperate()
return self.common_fn.run_test_case(lambda: self.common_fn.launch_app('4.0.1'),
lambda: start.baseOperate(),
lambda: self.app_installedList())
示例2: __init__
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class onekey_report:
def __init__(self):
self.com = CommonFunctions()
# 打开应用详情
def openDetailpage(self):
global app
try:
apps = self.com.driver.find_elements_by_id("com.tclmarket:id/name")
for app in apps:
if app.text != "":
app.click()
time.sleep(8)
appname = self.com.wait_for_element("com.tclmarket:id/name")
if appname.text == app.text:
print "you have entered appdetailpage"
self.com.swipe_screen(percent=0.7)
time.sleep(3)
return True
else:
print "you have entered wrong"
return False
except:
print "No app in the page"
return False
def onekeyVerify(self):
try:
report = self.com.wait_for_element("com.tclmarket:id/one_key_submit")
report.click()
report_message = self.com.wait_for_element("com.tclmarket:id/report_message")
report_items = self.com.driver.find_elements_by_id("com.tclmarket:id/linerlayout_two")
for item in report_items:
item.click()
submit = self.com.wait_for_element("com.tclmarket:id/submit")
report_message.send_keys(u"测试一件举报")
submit.click()
if report:
print "you back the detail page"
return True
else:
print "back failed"
return False
except:
s = sys.exc_info()
print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
return False
def run_onekey_report(self):
return self.com.run_test_case(
lambda: self.com.launch_app(), lambda: self.openDetailpage(), lambda: self.onekeyVerify()
)
示例3: open_app_of_apklists
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class open_app_of_apklists():
def __init__(self):
self.common_fn = CommonFunctions()
def app_homePage(self):
try:
manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
if manage_buttons[4].text==u'管理':
manage_buttons[4].click()
time.sleep(2)
print u'go into manage page\n'
else:
print u'manageButton[4].text do not equal to 管理'
except:
print u'not find manage button\n'
def app_installedList(self):
try:
self.app_homePage()
installed_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
installed_buttons[3].click()
time.sleep(2)
try:
title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
if title.text==u'安装包扫描':
print u'get apks list\n'
try:
appName = self.common_fn.wait_for_element(r'com.tclmarket:id/name').text
click_apps=self.common_fn.wait_for_elements(r'com.tclmarket:id/icon',By.ID)
click_apps[0].click()
print u'open app "%s" \n' % appName
self.common_fn.driver.keyevent('4')
base = baseFunc()
base.uninstallAPP(appName)
return True
except Exception as e:
print e
print u'not find apps\n'
return False
else:
return False
except:
return False
except:
print u'fail to go into installed apps page\n'
return False
def run(self):
start = startOperate()
return self.common_fn.run_test_case(lambda: self.common_fn.launch_app('4.0.1'),
lambda: start.baseOperate(),
lambda: self.app_installedList())
示例4: start_set_from_apkslist
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class start_set_from_apkslist():
def __init__(self):
self.common_fn = CommonFunctions()
def app_homepage(self):
try:
manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
if manage_buttons[4].text==u'管理':
manage_buttons[4].click()
time.sleep(2)
print u'go into manage page\n'
else:
print u'manage_button[4].text do not equal to 管理'
except:
print u'not find manage button\n'
def apks_list(self):
try:
apks_list_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
apks_list_buttons[3].click()
time.sleep(2)
print u'go into apks list page'
except:
print u'fail to go into apks list page'
def start_set_page(self):
try:
self.app_homepage()
self.apks_list()
set_button=self.common_fn.wait_for_element(r'com.tclmarket:id/actionbar_settings')
set_button.click()
time.sleep(2)
try:
title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
if title.text==u'设置':
print u'get set page\n'
return True
else:
return False
except:
print u'not get the title\n'
return False
except:
print u'fail to find set button\n'
return False
def run(self):
start = startOperate()
return self.common_fn.run_test_case(lambda: self.common_fn.launch_app('4.0.1'),
lambda: start.baseOperate(),
lambda: self.start_set_page())
示例5: __init__
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class commentpageVerify:
def __init__(self):
self.com = CommonFunctions()
# 打开应用详情
def openDetailpage(self):
try:
apps = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
for app in apps:
if app.text != '':
app.click()
time.sleep(5)
appname = self.com.wait_for_element('com.tclmarket:id/name')
if appname.text == app.text:
print 'you have entered appdetailpage'
self.com.swipe_screen(percent=0.7)
time.sleep(3)
return True
else:
print 'you have entered wrong'
return False
except:
print 'No app in the page'
return False
def commentpafeVerify(self):
try:
comment = self.com.wait_for_element('com.tclmarket:id/remark_tv')
comment.click()
time.sleep(5)
writeComment = self.com.wait_for_element('com.tclmarket:id/write_commment')
grade = self.com.wait_for_element('com.tclmarket:id/avgscore_lyout')
if writeComment and grade:
print 'You enter commentpage successfully'
return True
else:
print 'Enter the commentpage failure'
return False
except:
print 'commentpafe verify failure'
return False
def run_commentpafeVerify(self):
return self.com.run_test_case(lambda: self.com.launch_app(),
lambda: self.openDetailpage(),
lambda: self.commentpafeVerify())
示例6: __init__
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class HotpageVerify:
def __init__(self):
self.com = CommonFunctions()
def loadHotapps(self):
try:
# frame = self.com.driver.find_element_by_id('com.tclmarket:id/remark_layout')
# buttons = frame.find_elements_by_class_name('android.widget.RelativeLayout')
# for button in buttons:
# b = button.find_element_by_class_name('android.widget.TextView')
# if b.text == u'飙升':
# b.click()
# time.sleep(5)
# break
# return True
hot_button = self.com.wait_for_element(value='com.tclmarket:id/remark_text1', element_text=u'最热')
if hot_button:
hot_button.click()
return True
return False
except:
print 'No hot labels'
s = sys.exc_info()
print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
return False
def hotpageVerify(self):
time.sleep(2)
hot_title = self.com.wait_for_element(value='com.tclmarket:id/home_title', element_text=u'最热')
if hot_title:
apps = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
for app in apps:
if app.text != '':
print 'hotpage display normally'
return True
else:
print 'There is no app in hotpage.'
return False
def run_hotpageVerify(self):
return self.com.run_test_case(lambda: self.com.launch_app(),
lambda: self.loadHotapps(),
lambda: self.hotpageVerify())
示例7: __init__
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class loadHotapps:
def __init__(self):
self.com = CommonFunctions()
def loadHotapps(self):
try:
hot_button = self.com.wait_for_element(value='com.tclmarket:id/remark_text1', element_text=u'最热')
if hot_button:
hot_button.click()
return True
return False
except:
print 'No hot labels'
s = sys.exc_info()
print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
return False
def loadApps(self):
newapp_list = ''
while True:
try:
app_list = []
time.sleep(2)
buttons = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
for b in buttons:
app = b.text
app_list.append(app)
if app_list[-1] != newapp_list:
newapp_list = app_list[-1]
print 'loading app successfully'
self.com.swipe_screen()
time.sleep(10)
else:
print 'you load all app on the page'
return True
except:
print 'loadApps error'
s = sys.exc_info()
print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
return False
def run_loadHotapps(self):
return self.com.run_test_case(lambda: self.com.launch_app(),
lambda: self.loadHotapps(),
lambda: self.loadApps())
示例8: __init__
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class SearchpageVerify:
def __init__(self):
self.com = CommonFunctions()
def searchpageVerify(self):
button = self.com.wait_for_element('com.tclmarket:id/actionbar_search')
button.click()
time.sleep(5)
try:
frame = self.com.wait_for_element('com.tclmarket:id/keywordflow')
keywords = frame.find_elements_by_class_name('android.widget.TextView')
apps = self.com.wait_for_elements(value='com.tclmarket:id/name', by=By.ID)
for k in keywords:
if k.text != '':
print u'48小时热门搜索 is ok'
else:
print u'48小时热门搜索 Load Fail'
return False
for a in apps:
if a.text != '':
print u'search chats is ok'
else:
print u'search chats Load Fail'
return False
backicon = self.com.wait_for_element('com.tclmarket:id/actionbar_up')
backicon.click()
banner = self.com.wait_for_element('com.tclmarket:id/banner1')
if banner:
print 'You have successfully from the search page'
return True
else:
print 'wrong'
return False
except:
print 'searchpage Load Fail'
s = sys.exc_info()
print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
return False
def run_searchpageVerify(self):
return self.com.run_test_case(lambda: self.com.launch_app(),
lambda: self.searchpageVerify())
示例9: installedAppPage
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class installedAppPage():
def __init__(self):
self.common_fn = CommonFunctions()
def appHomePage(self):
try:
manageButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
if manageButtons[4].text==u'管理':
manageButtons[4].click()
time.sleep(2)
print u'go into manage page\n'
return True
else:
print u'manageButton[4].text do not equal to 管理'
return False
except:
print u'not find manage button\n'
return False
def appInstalledList(self):
try:
self.appHomePage()
installedButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
installedButtons[2].click()
time.sleep(2)
try:
title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
if title.text==u'已安装':
print u'get installed apps list\n'
return True
else:
return False
except:
return False
except:
print u'fail to go into installed apps page\n'
return False
def run(self):
start = startOperate()
return self.common_fn.run_test_case(lambda: self.common_fn.launch_app('4.0.1'),
lambda: start.baseOperate(),
lambda: self.appInstalledList())
示例10: __init__
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class searchIndetail:
def __init__(self):
self.com = CommonFunctions()
#打开应用详情
def openDetailpage(self):
global app
try:
apps=self.com.driver.find_elements_by_id('com.tclmarket:id/name')
for app in apps:
if app.text!='':
app.click()
time.sleep(5)
appname=self.com.wait_for_element('com.tclmarket:id/name')
if appname.text==app.text:
print 'you have entered appdetailpage'
return True
else:
print 'you have entered wrong'
return False
except:
print 'No app in the page'
return False
def opensearch(self):
try:
search=self.com.wait_for_element('com.tclmarket:id/actionbar_search')
search.click()
time.sleep(5)
frame=self.com.wait_for_element('com.tclmarket:id/keywordflow')
keywords=frame.find_elements_by_class_name('android.widget.TextView')
apps=self.com.driver.find_elements_by_id('com.tclmarket:id/name')
for k in keywords:
if k.text!='':
print u'48小时热门搜索 is ok'
break
else:
print u'48小时热门搜索 Load Fail'
return False
for a in apps:
if a.text !='':
print u'search chats is ok'
break
else:
print u'search chats Load Fail'
return False
backicon=self.com.wait_for_element('com.tclmarket:id/actionbar_up')
backicon.click()
appname=self.com.wait_for_element('com.tclmarket:id/name')
if appname.text==app.text:
print 'You successfully returns page for details'
return True
else:
print 'you have entered wrong'
return False
except:
print 'searchpage Load Fail'
return False
def run_searchIndetail(self):
return self.com.run_test_case(lambda: self.com.launch_app(),
lambda: self.openDetailpage(),
lambda: self.opensearch())
示例11: __init__
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class writecoment:
def __init__(self):
self.com = CommonFunctions()
# 打开应用详情ssss
def openDetailpage(self):
try:
apps = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
for app in apps:
if app.text != '':
app.click()
time.sleep(5)
appname = self.com.wait_for_element('com.tclmarket:id/name')
if appname.text == app.text:
print 'you have entered appdetailpage'
self.com.swipe_screen(percent=0.7)
time.sleep(3)
return True
else:
print 'you have entered wrong'
return False
except:
print 'No app in the page'
return False
def writecomment(self):
try:
comment = self.com.wait_for_element('com.tclmarket:id/remark_tv')
comment.click()
time.sleep(2)
writeComment = self.com.wait_for_element('com.tclmarket:id/write_commment')
writeComment.click()
commentbox = self.com.wait_for_element('com.tclmarket:id/comment_content')
submit = self.com.wait_for_element('com.tclmarket:id/submit_comment')
submit.click()
if commentbox:
print 'network is well'
else:
print 'pelase check your network'
return False
commentbox.send_keys(u'等等')
submit.click()
time.sleep(2)
if writeComment:
print 'You have successfully submit comments'
return True
return False
except:
print 'writecomment error '
return False
def run_writecoment(self):
return self.com.run_test_case(lambda: self.com.launch_app(),
lambda: self.openDetailpage(),
lambda: self.writecomment())
示例12: __init__
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class uninstalled_app:
def __init__(self):
self.common_fn = CommonFunctions()
def app_homePage(self):
try:
manage_buttons = self.common_fn.wait_for_elements(r"com.tclmarket:id/text", By.ID)
if manage_buttons[4].text == u"管理":
manage_buttons[4].click()
time.sleep(2)
print u"go into manage page\n"
else:
print u"manageButton[4].text do not equal to 管理"
except:
print u"not find manage button\n"
def app_installedList(self):
try:
self.app_homePage()
installed_buttons = self.common_fn.wait_for_elements(r"com.tclmarket:id/manage_image", By.ID)
installed_buttons[2].click()
time.sleep(2)
try:
title = self.common_fn.wait_for_element(r"com.tclmarket:id/home_title")
if title.text == u"已安装":
print u"get installed apps list\n"
try:
uninstall_name = self.common_fn.wait_for_element(r"com.tclmarket:id/name").text
uninstall_button = self.common_fn.wait_for_element(r"com.tclmarket:id/actionOne")
uninstall_button.click()
try:
uninstall_title = self.common_fn.wait_for_element(r"android:id/alertTitle")
if uninstall_title.text == uninstall_name:
print u"uninstall apps\n"
return True
else:
print u"can not uninstall apps\n"
return False
except:
s = sys.exc_info()
print "Error %s happend on line %d" % (s[1], s[2].tb_lineno)
return False
except:
s = sys.exc_info()
print "Error %s happend on line %d" % (s[1], s[2].tb_lineno)
print u"not find uninstall buttons\n"
return False
else:
return False
except:
s = sys.exc_info()
print "Error %s happend on line %d" % (s[1], s[2].tb_lineno)
return False
except:
s = sys.exc_info()
print "Error %s happend on line %d" % (s[1], s[2].tb_lineno)
print u"fail to go into installed apps page\n"
return False
def run(self):
start = startOperate()
return self.common_fn.run_test_case(
lambda: self.common_fn.launch_app("4.0.1"), lambda: start.baseOperate(), lambda: self.app_installedList()
)
示例13: apk_scanning_page
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
#.........这里部分代码省略.........
downloadBtn = app.find_element(By.ID,r'com.tclmarket:id/action_text')
if downloadBtn.text == u'下载':
downloadBtn.click()
appName = app.find_element(By.ID,r'com.tclmarket:id/name').text
isClick = True
break
if not isClick:
raise Exception('do not have download app at installedAppOpen')
print u'start to download an app\n'
time.sleep(50)
except:
print u'fail to download the first app\n '
try:
for i in range(4):
self.common_fn.element_clk(r'com.android.packageinstaller:id/ok_button')
#print u'click the next button %d\n' % (i+1)
time.sleep(30)
#print u'finish clicking ok\n'
except Exception as e:
print e
print u'something wrong with ok button\n'
return False
try:
self.common_fn.element_clk(r"com.android.packageinstaller:id/done_button")
time.sleep(2)
#print u'install the first app\n'
except:
print u'fail to install the first app\n'
return False
try:
download_apps=self.common_fn.wait_for_elements(r'com.tclmarket:id/action',By.ID)
download_apps[1].click()
print u'start to download the second app\n'
time.sleep(55)
except:
print u'fail to download the second app\n '
return False
try:
self.common_fn.wait_for_element(r'com.android.packageinstaller:id/cancel_button',time_out=90).click()
time.sleep(2)
print u'refuse to install downloaded apk\n'
except:
print u'fail to refuse install\n'
return False
finally:
self.common_fn.driver.remove_app('com.tencent.qqlive')
try:
manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
if manage_buttons[4].text==u'管理':
manage_buttons[4].click()
time.sleep(2)
print u'go into manage page\n'
else:
print u'manageButton[4].text do not equal to 管理'
return False
try:
action_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
action_texts=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_text',By.ID)
if action_texts[3].text==u'安装包扫描' :
action_buttons[3].click()
print u'get apks scanning page\n'
else:
print u'not get apks scanning page\n'
return False
try:
title=self.common_fn.wait_for_elements(r'com.tclmarket:id/header_text',By.ID)
base = baseFunc()
if title and len(title) == 1 and u'已安装' in title[0].text:
base.uninstallAPP(appName)
return True
elif title and len(title) == 2 and u'已安装' in title[0].text and u'未安装' in title[1].text:
#print u'installed apk is right\n'
base.uninstallAPP(appName)
return True
else:
print u'没有发现已安装或未安装列表'
return False
except:
print u'not find apks\n'
s = sys.exc_info()
print 'Error "%s" happend on line %d' % (s[1],s[2].tb_lineno)
return False
except:
print u'not find apks scanning button\n'
s = sys.exc_info()
print 'Error "%s" happend on line %d' % (s[1],s[2].tb_lineno)
return False
except:
print u'not find manage button\n'
s = sys.exc_info()
print 'Error "%s" happend on line %d' % (s[1],s[2].tb_lineno)
return False
def run(self):
start = startOperate()
return self.common_fn.run_test_case(lambda: self.common_fn.launch_app('4.0.1'),
lambda: start.baseOperate(),
lambda: self.app_homepage())
示例14: startSearchPage
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
#.........这里部分代码省略.........
downloadBtn = app.find_element(By.ID,r'com.tclmarket:id/action_text')
if downloadBtn.text == u'下载':
downloadBtn.click()
isClick = True
break
if not isClick:
raise Exception('do not have download app at installedAppOpen')
print u'start to download an app\n'
time.sleep(50)
except:
print u'fail to download the first app\n '
try:
for i in range(4):
self.common_fn.element_clk(r'com.android.packageinstaller:id/ok_button',timeout=50)
print u'click the next button %d\n' % (i+1)
time.sleep(30)
print u'finish clicking ok\n'
except:
print u'something wrong with ok button\n'
try:
doneButton=self.common_fn.element_clk(r"com.android.packageinstaller:id/done_button",timeout=30)
time.sleep(2)
print u'install the first app\n'
except:
print u'fail to install the first app\n'
try:
manageButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
if manageButtons[4].text==u'管理':
manageButtons[4].click()
time.sleep(2)
print u'go into manage page\n'
else:
print u'manageButton[4].text do not equal to 管理'
except:
print u'not find manage button\n'
s = sys.exc_info()
print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
def appDownloadTask(self):
try:
downloadTaskButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
downloadTaskButtons[0].click()
time.sleep(2)
print u'go into download task page'
except:
print u'fail to go into download task page'
def startSearchPage(self):
try:
self.appHomePage()
self.appDownloadTask()
appName = self.common_fn.wait_for_element(r'com.tclmarket:id/name').text
searchButton=self.common_fn.wait_for_element(r'com.tclmarket:id/actionbar_search')
searchButton.click()
time.sleep(2)
try:
findAppButton=self.common_fn.wait_for_element(r'com.tclmarket:id/search_editor')
if findAppButton.text==u'搜您喜欢的应用':
print u'get search page\n'
try:
gobackButton=self.common_fn.wait_for_element(r'com.tclmarket:id/actionbar_up')
gobackButton.click()
time.sleep(2)
try:
title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
if title:
print u'goback to download task page\n'
base = baseFunc()
base.uninstallAPP(appName)
return True
else:
print u'fail to goback to download task page\n'
return False
except:
s = sys.exc_info()
print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
return False
except:
print u'not find gobackButton\n'
return False
else:
print u'fail to get search page\n'
return False
except:
print u'not get the findAppButton'
return False
except:
print u'fail to find search button\n'
return False
finally:
self.common_fn.driver.remove_app('com.tencent.qqlive')
def run(self):
start = startOperate()
return self.common_fn.run_test_case(lambda: self.common_fn.launch_app('4.0.1'),
lambda: start.baseOperate(),
lambda: self.startSearchPage())
示例15: __init__
# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import run_test_case [as 别名]
class favoritesApp:
def __init__(self):
self.com = CommonFunctions()
# 打开应用详情
def openDetailpage(self):
global app
try:
apps = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
for app in apps:
if app.text != '':
app.click()
time.sleep(5)
return True
else:
print 'loading recommend app failure'
return False
except:
print 'No app in the page'
return False
# 登录并收藏应用
def favoriteApp(self):
try:
shareicon = self.com.wait_for_element('com.tclmarket:id/left_btn_image')
appname = self.com.wait_for_element('com.tclmarket:id/name')
if appname.text == app.text:
print 'you have entered appdetailpage'
else:
print 'you have entered wrong'
return False
shareicon.click()
time.sleep(5)
input_texts = self.com.driver.find_elements_by_class_name('android.widget.EditText')
input_texts[0].send_keys(u'[email protected]')
input_texts[1].send_keys(u'wll82441985')
button = self.com.driver.find_element_by_class_name('android.widget.Button')
button.click()
time.sleep(8)
shareicon = self.com.wait_for_element('com.tclmarket:id/left_btn_image')
shareicon.click()
time.sleep(5)
back_button = self.com.wait_for_element('com.tclmarket:id/actionbar_up')
if back_button:
back_button.click()
return True
else:
return False
except:
print 'favoriteApp error'
return False
# 验证收藏是否成功
def checkFavoriteapp(self):
try:
tab = self.com.wait_for_element('com.tclmarket:id/tab_indicator')
buttons = tab.find_elements_by_class_name('android.widget.TextView')
for b in buttons:
if u'我的' in b.text:
b.click()
time.sleep(3)
break
F_button = self.com.wait_for_element('com.tclmarket:id/favorite')
F_button.click()
time.sleep(5)
F_apps = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
if F_apps[0].text == app.text:
print 'Successful collection application'
return True
else:
print 'Collect application failure'
return False
except:
print 'checkFavoriteapp error'
return False
def run_favoritesApp(self):
return self.com.run_test_case(lambda: self.com.launch_app(),
lambda: self.openDetailpage(),
lambda: self.favoriteApp(),
lambda: self.checkFavoriteapp())