def add_email_account(self, user_name, user_pwd): ''' add an email account @type user_name: string @param user_name: email user name. @type user_pwd: string @param user_pwd: email user password. @return: True: login successful; False: no. ''' #Add Email Account ime = IME() start_activity('com.android.settings', '.Settings') scroll_to_bottom() click_textview_by_text(self.get_value("add_account_label"), 1, 0) click_textview_by_text(self.get_value("app_email"), 1, 0) #input account click_textview_by_id("account_email", 1, 0) ime.IME_input(1, user_name) #input password ime.IME_input(1, user_pwd) #entertext_edittext_by_id("account_password",SC.PRIVATE_EMAIL_EMAIL_PASSWORD,1,0) sleep(1) click_button_by_id("next", 1, 0) click_button_by_id("pop", 1, 0) scroll_to_bottom() click_button_by_id("next", 1, 0) if not search_text(self.get_value("account_duplicate_dlg_title"), 1, 0): time = 0 while (search_text( self.get_value( "account_setup_check_settings_check_incoming_msg"), 1, 0) or search_text(self.get_value("could_not_open_connection"), 1, 0)) and time < 3: sleep(2) if search_text(self.get_value("could_not_open_connection"), 1, 0): goback() time = time + 1 click_button_by_id("next", 1, 0) if time == 3: return False else: click_imageview_by_id("account_security_type", 1, 0) click_textview_by_text(self.get_value("ssl_tls"), 1, 0) scroll_to_bottom() click_button_by_id("next", 1, 0) time = 0 while (search_text( self.get_value( "account_setup_check_settings_check_outgoing_msg"), 1, 0) or search_text( self.get_value("could_not_open_connection"), 1, 0)) and time < 3: sleep(3) if search_text(self.get_value("could_not_open_connection"), 1, 0): goback() time = time + 1 click_button_by_id("next", 1, 0) if time == 3: return False fun = lambda: search_view_by_id("next") wait_for_fun(fun, True, 10) click_button_by_id("next", 1, 0) sleep(3) click_textview_by_id("account_name", 1, 0) clear_edittext_by_id("account_name", 1, 0) sleep(1) ime.IME_input_english(1, "autotest") #entertext_edittext_by_id("account_name",SC.PRIVATE_EMAIL_ACCOUNT_NAME,1,0) click_button_by_id("next", 1, 0) sleep(1) goback() goback() return True else: goback() goback() goback() goback() goback() return False
class test_suit_contacts_case2(TestCaseBase): def call_from_contact(self): """ This function call from contact. @return: none """ log_test_case(self.name, 'call_from_contact') #lick_textview_by_text(SC.PRIVATE_CONTACT_NUMBER) click_textview_by_id('primary_action_view') sleep(1) goback() sleep(3) return def test_case_main(self, case_results): """ main function ,entry search and show contact record @return: none """ log_test_case(self.name, 'drag up and down') drag_by_param(95, 50, 95, 85, 1) drag_by_param(95, 85, 95, 50, 1) sleep(1) drag_by_param(95, 50, 95, 85, 1) drag_by_param(95, 85, 95, 50, 1) sleep(1) self.ime = IME() click_imageview_by_id('menu_search') #entertext_edittext_on_focused('Mi') #clear_edittext_by_index(0) ''' PRIVATE_del = ['del'] self.ime.IME_input(1, PRIVATE_del) self.ime.IME_input(1, PRIVATE_del) self.ime.IME_input(1, PRIVATE_del) ''' self.ime.IME_input_english(1, 'tes') sleep(2) if search_text(SC.PRIVATE_CONTACT_NAME): log_test_case(self.name, 'search name ok...') click_textview_by_text(SC.PRIVATE_CONTACT_NAME) #click_in_list_by_index(1) else: log_test_case(self.name, 'search failed...') return self.call_from_contact() #send sms to mike click_textview_by_id('secondary_action_button') self.ime.IME_input_english(1, 'send') #click_imageview_by_desc("send") click_button_by_id('send_button_sms') sleep(3) goback() #click_textview_by_text('binz') # show a moment sleep(1) #send EMAIL if search_text('*****@*****.**'): click_textview_by_text('*****@*****.**') # if search_text('Complete action using'): click_textview_by_text('Email') click_button_by_id('button_always') entertext_edittext_on_focused('email title') click_imageview_by_id("send") else: goback() # go address map scroll_to_bottom() if search_text('ADDRESS'): click_textview_by_text('pudong,shanghai,china') else: goback()
class PlayStore(Base): ''' PlayStore is a class for operating google play store application. @see: L{Base <Base>} ''' TAG = "PlayStore" '''@var TAG: tag of PlayStore''' def __init__(self): ''' init function. ''' self.mode_name = "playstore" Base.__init__(self, self.mode_name) self.ime = IME() self.debug_print('PlayStore init:%f' % (time.time())) def download(self, name, description): ''' download a application according to the application name and description. @type name: string @param name: application's name @type description: string @param description: applicaiton's description that is company name in most situations. @return: true-if the application download success,false-if the application download failed. ''' click_button_by_id("search_button") #entertext_edittext_on_focused(name) click_textview_by_id("search_src_text") self.ime.IME_input_english(1, name) send_key(KEY_ENTER) sleep(20) click_textview_by_text(description) sleep(20) if search_text(self.get_value("uninstall")): log_test_framework( self.TAG, "find uninstall button," + name + " has been installed.") return True if search_text(self.get_value("install")): click_button_by_id("buy_button") click_button_by_id("acquire_button") click_imageview_by_id("home") pre_time = time.time() running = True while running: if search_text(self.get_value("uninstall")): running = False log_test_framework(self.TAG, "download " + name + " successed.") return True if time.time() - pre_time > 10 * 60: running = False log_test_framework(self.TAG, "download " + name + " time out.") click_button_by_id(self.TAG, "cancel_download") log_test_framework(self.TAG, "cancel download " + name) return False else: log_test_framework( self.TAG, "error in find install button interface, download " + name + " error.") return False