Exemplo n.º 1
0
    def test_MOVoLTE(self):
        prefix = C_Dialer.PREFIX
        logging.info('{0}_MOVoLTE: START'.format(prefix))
        wait_el_id_click(self.Odriver, C_Dialer.ID_BTN_FLOAT)

        for n in C_Dialer.REF_PHONE_NUM:
            wait_el_id_click(self.Odriver, C_Dialer.number(self, n))
        time.sleep(10)

        btn_call = wait_el_id(self.Odriver, C_Dialer.ID_BTN_DIALPAD_FLOAT, 10)
        if btn_call is None:
            self.fail('{0}: Wait to long for the call.'.format(prefix))
        action(btn_call, Commands.CLICK)

        btn_swipe_to_answer = wait_el_id(self.Tdriver,
                                         C_Dialer.ID_SWIPE_TO_ANSWER, 10)
        width = self.Tdriver.get_window_size()['width']
        height = self.Tdriver.get_window_size()['height']
        TouchAction(self.Tdriver).press(btn_swipe_to_answer).move_to(
            x=width / 2, y=height / 3)

        call_time = C_Dialer.CALL_TIME
        timeout = time.time() + 60 * call_time
        logging.info('{0}: Play for {1} miuntes'.format(prefix, call_time))
        while time.time() < timeout:
            if (int(timeout - time.time())) % 20 == 0:
                self.Odriver.get_window_size()
                self.Tdriver.get_window_size()
                logging.info('{0}: In Call'.format(prefix))
                time.sleep(5)

        wait_el_id_click(self.Odriver, C_Dialer.ID_BTN_END_CALL)

        logging.info('{0}_MOVoLTE: END'.format(prefix))
Exemplo n.º 2
0
    def setUp(self):
        if not self.flag:
            logging.info(
                'test_dialer: There is only one device, can not take a interacted call test.'
            )
            self.fail(
                'test_dialer: There is only one device, can not take a interacted call test.'
            )

        if self.Odriver == None or self.Tdriver == None:
            self.fail('Camera: Get webdriver unsucceed.')

        self.Odriver.launch_app()
        self.Tdriver.launch_app()
Exemplo n.º 3
0
def runTest():
    times = 1
    timeout = time.time() + 60 * 1  # 24h = 60*60*24
    timestr = time.strftime('%Y_%m_%d_%H.%M.%S', time.localtime(time.time()))

    filename = "./logs/" + timestr + ".html"
    with open(filename, 'wb') as f:
        while True:
            if time.time() > timeout:
                logging.info('TEST OVER')
                break
            else:
                runner = HTMLTestRunner.HTMLTestRunner(
                    stream=f,
                    title=u'Test Report: {0}'.format(times),
                    description=u'24 test case, test by TG')
                logging.info('Test Times: {0}'.format(times))
                times += 1
                runner.run(suite())
Exemplo n.º 4
0
    def initM(self, num):
        """
    Init messaging's recipients and make text editor prepared
    """
        prefix = C_Messaging.PREFIX
        if not wait_el_xpath_click(self.driver, C_Messaging.PATH_BTN_CREATE):
            logging.info('{0}: Create new message unsucceed.'.format(prefix))
            self.fail('{0}: Create new message unsucceed.'.format(prefix))
        recipients = wait_el_xpath(self.driver, C_Messaging.PATH_RECIPIENTS)
        action(recipients, Commands.CLEAR)
        action(recipients, Commands.CLICK)

        # phone number: 147 8230 5348
        for s in num:
            self.driver.press_keycode(Keycode.get(self, s))

        self.driver.press_keycode(Keycode.ENTER)

        text_editor = wait_el_xpath(self.driver, C_Messaging.PATH_TEXT_EDITOR)
        return text_editor
Exemplo n.º 5
0
    def test_wlan_disable(self):
        prefix = C_WLAN.PREFIX_D
        logging.info('{0}: START'.format(prefix))
        switch_wlan = self.initW()
        if switch_wlan is None:
            self.fail('{0}: WLAN Switch load unsucceed.'.format(prefix))

        if value(switch_wlan, Commands.TEXT) == C_WLAN.WLAN_ENABLED:
            action(switch_wlan, Commands.CLICK)
            logging.info('{0}: WLAN disable succeed.'.format(prefix))
        else:
            logging.info('{0}: WLAN is already disabled.'.format(prefix))
        sleep(3)
        logging.info('{0}: END'.format(prefix))
Exemplo n.º 6
0
    def test_bluetooth_disable(self):

        prefix = C_Bluetooth.PREFIX_D
        logging.info('{0}: START'.format(prefix))
        switch_bluetooth = self.initB()
        if switch_bluetooth is None:
            self.fail('{0}: Bluetooth Switch load unsucceed.'.format(prefix))

        if value(switch_bluetooth,
                 Commands.TEXT) == C_Bluetooth.BLUETOOTH_ENABLED:
            action(switch_bluetooth, Commands.CLICK)
            logging.info('{0}: Bluetooth disable succeed.'.format(prefix))
        else:
            logging.info('{0}: Bluetooth is already disabled.'.format(prefix))
        sleep(3)
        logging.info('{0}: END'.format(prefix))
Exemplo n.º 7
0
 def test_candy_crush(self):
     prefix = C_CandyCrush.PREFIX
     sleep(30)
     logging.info('{0}: START'.format(prefix))
     login_close_x = C_CandyCrush.LOGIN_CLOSE_X
     login_close_y = C_CandyCrush.LOGIN_CLOSE_Y
     settings_x = C_CandyCrush.SETTINGS_X
     settings_y = C_CandyCrush.SETTINGS_Y
     os.popen('adb shell input tap {0} {1}'.format(login_close_x,
                                                   login_close_y))
     logging.info('{0}: Close Logging popup.'.format(prefix))
     sleep(3)
     os.popen('adb shell input tap {0} {1}'.format(settings_x, settings_y))
     sleep(3)
     logging.info('{0}: Open settings.'.format(prefix))
     logging.info('{0}: END'.format(prefix))
Exemplo n.º 8
0
def my_webdriver(
  app,
  host = '127.0.0.1',
  port = 4723,
  device_name = devices_id[0],
  auto_grant_permissions = True,
  no_reset = False,
  full_reset = False,
  system_port = 8200,
  newCommandTimeout = 60,
  app_path = ''):

  desired_caps = {
    'appPackage': app[1],
    'appActivity': app[2],
    'platformName': 'Android',
    'platformVersion': os_version(device_name),
    'deviceName': device_name,
    'autoGrantPermissions': auto_grant_permissions,
    'noReset': no_reset,
    'fullReset': full_reset,
    'systemPort': system_port,
    'newCommandTimeout': newCommandTimeout,
    'app': app_path,
    'udid': device_name,
    # 'unicodeKeyboard': True,
    # 'resetKeyboard': True,
    'noSign': True,
    'automationName': 'UiAutomator2'
  }

  try:
    return webdriver.Remote('http://{0}:{1}/wd/hub'.format(host, port), desired_caps)
  except Exception as e:
    logging.info('please confirm if the appium server is running.')
    logging.debug('Exception: {0}, Please confirm if the appium server is running.'.format(e))
    return None
Exemplo n.º 9
0
    def test_SMS_MO(self):
        prefix = C_Messaging.PREFIX_O
        logging.info('{0}: START'.format(prefix))

        text_editor = self.initM(C_Messaging.REF_PHONE_NUM)
        if text_editor is None:
            logging.info('{0}: Text editor load unsucceed.'.format(prefix))
            self.fail('{0}: Text editor load unsucceed.'.format(prefix))
        else:
            btn_send_sms = wait_el_xpath(self.driver,
                                         C_Messaging.PATH_BTN_SEND_SMS)
            action(text_editor, Commands.CLICK)
            action(text_editor, Commands.SEND_KEYS, C_Messaging.DEFAULT_MSG)
            action(btn_send_sms, Commands.CLICK)
            logging.info('{0}: Send a SMS to reference phone.'.format(prefix))
            sleep(10)
            self.driver.back()
            logging.info('{0}: END'.format(prefix))
Exemplo n.º 10
0
    def test_music_network(self):
        prefix = C_Tune.PREFIX
        logging.info('{0}: START'.format(prefix))
        time.sleep(20)
        if wait_el_xpath(self.driver, C_Tune.PATH_HOMEPAGE) is not None:
            time.sleep(5)
            os.open("adb shell input tap {0} {1}".format(
                C_Tune.CLOSE_HOMEPAGE_X, C_Tune.CLOSE_HOMEPAGE_Y))
        else:
            logging.info('{0}: No need to initialize Tune.'.format(prefix))
        wait_el_xpath_click(self.driver, C_Tune.PATH_BTN_SEARCH)
        et_search = wait_el_xpath(self.driver, C_Tune.PATH_ET_SEARCH)
        if et_search is None:
            self.fail('{0}: Load unsucceed.'.format(prefix))
        else:
            action(et_search, Commands.SEND_KEYS, 'love')
            self.driver.press_keycode(Keycode.ENTER)
            song_1st = wait_el_xpath(self.driver, C_Tune.PATH_MUSIC_1ST, 30)
            if song_1st is None:
                self.fail(
                    '{0}: Please check if there is network or it is very slow.'
                    .format(prefix))
            else:
                action(song_1st, Commands.CLICK)
                if not wait_el_xpath_click(self.driver,
                                           C_Tune.PATH_BTN_PROFILE_PLAY, 30):
                    self.fail(
                        '{0}: Please check if there is network or it is very slow.'
                        .format(prefix))
                else:
                    play_minutes = C_Tune.PLAY_MINUTES
                    timeout = time.time() + 60 * play_minutes
                    logging.debug('{0}: Play for {1} minutes'.format(
                        prefix, play_minutes))
                    while time.time() < timeout:
                        if (int(timeout - time.time())) % 20 == 0:
                            self.driver.get_window_size()
                            logging.info('{0}: Playing'.format(prefix))
                            time.sleep(5)

        logging.info('{0}: END'.format(prefix))
Exemplo n.º 11
0
    def test_MMS_MO(self):
        prefix = C_Messaging.PREFIX_T
        logging.info('{0}: START'.format(prefix))

        text_editor = self.initM(C_Messaging.REF_PHONE_NUM)

        if text_editor is None:
            logging.info('{0}: Text editor load unsucceed.'.format(prefix))
            self.fail('{0}: Text editor load unsucceed.'.format(prefix))
        else:
            wait_el_xpath_click(self.driver, C_Messaging.PATH_ADD_ATTACH)
            wait_el_xpath_click(self.driver, C_Messaging.PATH_ATTACH_SUBJECT)
            et_subject = wait_el_xpath(self.driver,
                                       C_Messaging.PATH_ET_SUBJECT)
            action(et_subject, Commands.SEND_KEYS, C_Messaging.DEFAULT_SUBJECT)
            action(text_editor, Commands.CLICK)
            action(text_editor, Commands.SEND_KEYS, C_Messaging.DEFAULT_MSG)
            btn_send_mms = wait_el_xpath(self.driver,
                                         C_Messaging.PATH_BTN_SEND_MMS)
            action(btn_send_mms, Commands.CLICK)
            logging.info('{0}: Send a MMS to reference phone.'.format(prefix))
            sleep(10)
            self.driver.back()
            logging.info('{0}: END'.format(prefix))
Exemplo n.º 12
0
    def test_video_playback(self):
        prefix = C_Video.PREFIX
        play_minutes = C_Video.PLAY_MINUTES

        logging.info('{0}: START'.format(prefix))

        time.sleep(3)
        videos = wait_els_xpath(self.driver, C_Video.PATH_VIDEOS)
        if videos is None:
            logging.info('{0}: Check if there are videos'.format(prefix))
            self.fail("{0}: No Videos".format(prefix))

        logging.debug('{0}: Play each video for {1} minutes'.format(
            prefix, play_minutes / 3))
        for video in videos:
            logging.info('{0}: {1} is playing'.format(
                prefix, value(video, Commands.TEXT)))
            time.sleep(1)

            action(video, Commands.CLICK)
            timeout = time.time() + 20 * play_minutes

            select_play = wait_el_xpath(self.driver, C_Video.PATH_SELECT_PLAY,
                                        3)
            if select_play is not None:
                action(select_play, Commands.CLICK)
            wait_el_xpath_click(self.driver, C_Video.PATH_BTN_ALWAYS, 2)

            if wait_el_xpath_click(self.driver, C_Video.BTN_ALLOW, 3):
                logging.info('{0}: Permission Allowed.'.format(prefix))

            if wait_el_xpath_click(self.driver, C_Video.PATH_START_OVER, 3):
                logging.info('{0}: Start Over'.format(prefix))

            while time.time() < timeout:
                if (int(timeout - time.time())) % 20 == 0:
                    self.driver.get_window_size()
                    logging.info('{0}: Playing'.format(prefix))
                    time.sleep(5)

            if wait_el_xpath(self.driver, C_Video.PATH_VIDEOS) is None:
                self.driver.back()
            else:
                continue

        logging.info('{0}: END'.format(prefix))
Exemplo n.º 13
0
    def test_music_palyback(self):
        prefix = C_Music.PREFIX
        logging.info('{0}: START'.format(prefix))
        if not wait_el_xpath_click(self.driver, C_Music.PATH_BTN_SKIP):
            logging.info(
                '{0}: No need to initialize Google Music.'.format(prefix))

        wait_el_xpath_click(self.driver, C_Music.PATH_NAV_LISTEN_NOW)
        time.sleep(3)
        if not wait_el_xpath_click(self.driver, C_Music.PATH_SHUFFLE_ALL):
            self.fail('{0}: If there are musics.'.format(prefix))
            logging.info('{0}: If there are musics.'.format(prefix))
        logging.info('{0}: Shuffle all of the music.'.format(prefix))
        btn_pause_play = wait_el_xpath(self.driver,
                                       C_Music.PATH_BTN_PAUSE_PLAY)

        while value(btn_pause_play,
                    Commands.TAG_NAME) == C_Music.STATUS_PLAYING:
            logging.info('{0}: Playing'.format(prefix))
            time.sleep(5)

        logging.info('{0}: END'.format(prefix))
Exemplo n.º 14
0
    def test_take_picture(self):
        prefix = C_Camera.PREFIX
        logging.info('{0}: START'.format(prefix))
        if not wait_el_xpath_click(self.driver, C_Camera.PATH_BTN_YES):
            logging.info('{0}: No need to initialize Camera.'.format(prefix))
        if not wait_el_xpath_click(self.driver, C_Camera.PATH_BTN_GOT):
            logging.info(
                "{0}: It's not the 1st time run app in full screen.".format(
                    prefix))
        sleep(5)
        btn_shutter = wait_el_xpath(self.driver, C_Camera.PATH_SHUTTER)
        if btn_shutter is None:
            wait_el_xpath_click(self.driver, C_Camera.PATH_CAMERA_SWITCHER)
            wait_el_xpath_click(self.driver, C_Camera.PATH_PHOTO_SWITCHER)
            logging.info('{0}: Switch to Photo.'.format(prefix))
            wait_el_xpath_click(self.driver, C_Camera.PATH_SHUTTER)
        else:
            action(btn_shutter, Commands.CLICK)

        sleep(8)
        logging.info('{0}: Take a photo.'.format(prefix))
        logging.info('{0}: END'.format(prefix))
Exemplo n.º 15
0
        Settings(Tests.BLUETOOTH_DISABLE),  # OK
        Settings(Tests.BLUETOOTH_ENABLE),  # Headset Needed
        Settings(Tests.WLAN_DISABLE),  # OK
        Settings(Tests.WLAN_ENABLE),  # OK
        CandyCrush(Tests.CANDY_CRUSH),  # OK
        Camera(Tests.TAKE_PICTURE),  # OK
        Messaging(Tests.SMS_MO),  # OK
        Messaging(Tests.MMS_MO),  # OK
        GoogleMaps(Tests.MULTI_LAYERS),  # OK
        GoogleChrome(Tests.TEN_WEBSITES),  # OK
        GoogleMusic(Tests.MUSIC_PLAYBACK),  # OK
        Tune(Tests.MUSIC_NETWORK),  # OK
        Video(Tests.VIDEO_PLAYBACK),  # OK
        Youtube(Tests.VIDEO_NETWORK),  # OK
        Dialer(Tests.MOVILTE),
        Dialer(Tests.MOVOLTE),
        Dialer(Tests.MTVOLTE),
        Dialer(Tests.VO2VI2VO)
    ]
    suite.addTests(tests)
    return suite


if __name__ == "__main__":
    try:
        runTest()
    except Exception as e:
        logging.info('Exception: {0}'.format(e))
        logging.debug('Exception: {0}'.format(traceback.format_exc()))
    finally:
        print('Please check the Reports.')
Exemplo n.º 16
0
    def test_ten_websites(self):
        prefix = C_Browser.PREFIX
        logging.info('{0}: START'.format(prefix))
        if wait_el_xpath_click(self.driver, C_Browser.PATH_BTN_TERMS_ACCEPT,
                               5):
            wait_el_xpath_click(self.driver, C_Browser.PATH_BTN_NEGATIVE, 20)
            wait_el_xpath_click(self.driver,
                                C_Browser.PATH_BTN_UNCHANGE_SEARCH, 5)
        else:
            logging.info(
                '{0}: No need to initialize Google Chrome.'.format(prefix))

        if wait_el_xpath_click(self.driver, C_Browser.PATH_SEARCH_BOX, 10):
            logging.info('{0}: There is HomePage.'.format(prefix))

        url_bar = wait_el_xpath(self.driver, C_Browser.PATH_URL_BAR, 10)
        if url_bar is None:
            logging.info('{0}: URL bar load unsucceed.'.format(prefix))
            self.fail('{0}: URL bar load unsucceed.'.format(prefix))

        sites = C_Browser.SITES
        for site in sites:
            logging.info('{0}: {1}'.format(prefix, site))
            action(url_bar, Commands.CLICK)
            action(url_bar, Commands.CLEAR)
            action(url_bar, Commands.SEND_KEYS, site)
            self.driver.press_keycode(Keycode.ENTER)
            sleep(20)

        logging.info('{0}: END'.format(prefix))
Exemplo n.º 17
0
 def test_video_network(self):
     play_minutes = C_Youtube.PLAY_MINUTES
     prefix = C_Youtube.PREFIX
     logging.info('{0}: START'.format(prefix))
     home_1st_video = wait_el_xpath(self.driver,
                                    C_Youtube.PATH_HOME_1ST_VIDEO, 30)
     if home_1st_video is None:
         logging.info('{0}: Check if there is network.'.format(prefix))
         logging.info('{0}: END'.format(prefix))
         self.fail('No network.')
     else:
         action(home_1st_video, Commands.CLICK)
         timeout = time.time() + 60 * play_minutes
         logging.info('{0}: Play for {1} miuntes'.format(
             prefix, play_minutes))
         while time.time() < timeout:
             if (int(timeout - time.time())) % 20 == 0:
                 self.driver.get_window_size()
                 logging.info('{0}: Playing'.format(prefix))
                 time.sleep(5)
         logging.info('{0}: END'.format(prefix))
Exemplo n.º 18
0
    def test_bluetooth_enable(self):

        headset_name = C_Bluetooth.HEADSET_NAME
        prefix = C_Bluetooth.PREFIX_E
        logging.info('{0}: START'.format(prefix))
        switch_bluetooth = self.initB()
        if switch_bluetooth is None:
            self.fail('{0}: Bluetooth Switch load unsucceed.'.format(prefix))

        if value(switch_bluetooth,
                 Commands.TEXT) == C_Bluetooth.BLUETOOTH_DISABLED:
            action(switch_bluetooth, Commands.CLICK)
            logging.info('{0}: Bluetooth enable succeed.'.format(prefix))
        else:
            logging.info('{0}: Bluetooth is already enabled.'.format(prefix))

        sleep(5)
        while True:
            if wait_el_xpath_click(self.driver,
                                   C_Bluetooth.PATH_DEVICES_1ST_SETTINGS, 3):
                wait_el_xpath_click(self.driver, C_Bluetooth.PATH_BTN_FOGET)
                logging.info('{0}: Forget remmerbered devices.'.format(prefix))
                sleep(2)
            else:
                break

        wait_el_xpath_click(self.driver, C_Bluetooth.PATH_PAIR_NEW_DEVICE)
        if wait_el_xpath_click(self.driver, C_Bluetooth.PATH_HEADSET, 10):
            sleep(8)
            wait_el_xpath_click(self.driver, C_Bluetooth.PATH_BTN_PAIR)
            sleep(8)
            if wait_el_xpath(self.driver, C_Bluetooth.PATH_AVAILABLE_DEVICES,
                             3) is not None:
                logging.info(
                    '{0}: Pair with {1} unsucceed, Headset no response.'.
                    format(prefix, headset_name))
                self.fail('{0}: Pair with {1} unsucceed, Headset no response.'.
                          format(prefix, headset_name))
        else:
            self.fail('{0}: There is not a headset named {1}.'.format(
                prefix, headset_name))

        if wait_el_xpath(self.driver, C_Bluetooth.PATH_DEVICES_1ST_SETTINGS,
                         3) is None:
            logging.info('{0}: Pair with {1} unsucceed.'.format(
                prefix, headset_name))
            self.fail('{0}: {1} not found.'.format(
                prefix, C_Bluetooth.PATH_DEVICES_1ST_SETTINGS))
        else:
            logging.info('{0}: Pair with {1} succeed.'.format(
                prefix, headset_name))
        sleep(3)
        logging.info('{0}: END'.format(prefix))
Exemplo n.º 19
0
  def test_multi_layers_no_reset(self):
    prefix = C_Maps.PREFIX
    logging.info('{0}: START'.format(prefix))
    sleep(3)
    if wait_el_xpath_click(self.driver, C_Maps.PATH_PAGE_SKIP, 3):
      logging.info('{0}:Launch Google Maps 1st time.'.format(prefix))
    else:
      logging.info('{0}: No need to initialize Google Maps.'.format(prefix))

    sleep(8)
    if wait_el_xpath_click(self.driver, C_Maps.PATH_BTN_COMPASS):

      map_list = [
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_DEFAULT),     # type_default
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_SATELLITE),   # type_satellite
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_TERRAIN)      # type_terrain
      ]
      details_list = [
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_TRANSIT),     # type_transit
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_TRAFFIC),     # type_traffic
        wait_el_xpath(self.driver, C_Maps.PATH_MAP_TYPE_BICYCLING)    # type_bicycling
      ]

      for m in map_list:
        action(m, Commands.CLICK)
        sleep(3)
        for d in details_list:
          action(d, Commands.CLICK)
          logging.info('{0}: {1} - {2}'.format(prefix, value(m, Commands.TEXT), value(d, Commands.TEXT)))
          sleep(3)
      wait_el_xpath_click(self.driver, C_Maps.PATH_BTN_CLOSE_COMPASS)
    else:
      nav_menu = wait_el_xpath(self.driver, C_Maps.PATH_NAV_MENU)
      if not nav_menu:
        logging.info('{0}: Navgiate menu load unsucceed.'.format(prefix))
        self.fail('{0}: Navgiate menu load unsucceed.'.format(prefix))
      else:
        action(nav_menu, Commands.CLICK)
        traffic_types = wait_els_xpath(self.driver, C_Maps.PATH_NAV_TYPES, 10)

        for type in traffic_types:
          logging.info('{0}: {1}'.format(prefix, value(type, Commands.TEXT)))
          action(type, Commands.CLICK)
          sleep(6)
          action(nav_menu, Commands.CLICK)

        action(traffic_types[0], Commands.CLICK)

        sleep(5)

    logging.info('{0}: END'.format(prefix))
Exemplo n.º 20
0
 def test_get_memory_status(self):
     prefix = C_Memorry.PREFIX
     logging.info('{0}: START'.format(prefix))
     sleep(5)
     if wait_el_xpath_click(self.driver, C_Settings.PATH_MEMORY):
         sleep(5)
         if wait_el_xpath(self.driver, C_Memorry.PATH_DONUT) is not None:
             logging.info('{0}: There is no sd card.'.format(prefix))
             tv_total_memory = wait_el_xpath(self.driver,
                                             C_Memorry.PATH_TOTAL_MEMORY)
             tv_used = wait_el_xpath(self.driver, C_Memorry.PATH_USED)
             logging.info('{0}: {1} {2}'.format(
                 prefix, value(tv_used, Commands.TEXT),
                 value(tv_total_memory, Commands.TEXT)))
         else:
             logging.info('{0}: There is a sd card.')
             tv_used_c = wait_el_xpath(self.driver, C_Memorry.PATH_USED_C)
             tv_total_c = wait_el_xpath(self.driver, C_Memorry.PATH_TOTAL_C)
             logging.info('{0}: {1} {2}'.format(
                 prefix, value(tv_used_c, Commands.TEXT),
                 value(tv_total_c, Commands.TEXT)))
         sleep(2)
     else:
         self.fail('{0}: Memory load unsucceed.'.format(prefix))
     sleep(3)
     logging.info('{0}: END'.format(prefix))
Exemplo n.º 21
0
    def test_wlan_enable(self):
        ap_point_name = C_WLAN.AP_POINT_NAME
        prefix = C_WLAN.PREFIX_E
        logging.info('{0}: START'.format(prefix))
        switch_wlan = self.initW()
        if switch_wlan is None:
            self.fail('{0}: WLAN Switch load unsucceed.'.format(prefix))

        if value(switch_wlan, Commands.TEXT) == C_WLAN.WLAN_DISABLED:
            action(switch_wlan, Commands.CLICK)
            logging.info('{0}: WLAN enable succeed.'.format(prefix))
            sleep(5)
        else:
            logging.info('{0}: WLAN is already enabled.'.format(prefix))
            sleep(3)

        ap_connected = wait_el_xpath(self.driver, C_WLAN.PATH_AP_CONNECTED)
        if ap_connected is not None:
            action(ap_connected, Commands.CLICK)
            wait_el_xpath_click(self.driver, C_WLAN.PATH_AP_FORGET)

        sleep(3)
        swipe_times = 10

        while True:
            ap_point = wait_el_xpath(self.driver, C_WLAN.PATH_AP_POINT, 3)
            if ap_point is None:
                add_network = wait_el_xpath(self.driver,
                                            C_WLAN.PATH_ADD_NETWORK, 3)
                if add_network is None:
                    if swipe_times != 0:
                        swipe_times = swipe_times - 1
                        logging.info('{0}: AP did not found'.format(prefix))
                        logging.info(
                            "{0}: Try swipe up to find the AP '{1}', times: {2}"
                            .format(prefix, ap_point_name, 10 - swipe_times))
                        MobileSwipe.swipe_up(self, self.driver, 800)
                        sleep(1)
                        continue
                    else:
                        logging.info('{0}: There is no AP named {1}'.format(
                            prefix, ap_point_name))
                        break
                else:
                    action(add_network, Commands.CLICK)
                    logging.info(
                        '{0}: Try to add network manually.'.format(prefix))
                    et_ssid = wait_el_xpath(self.driver, C_WLAN.PATH_ET_SSID)
                    action(et_ssid, Commands.CLICK)
                    action(et_ssid, Commands.CLEAR)
                    action(et_ssid, Commands.SEND_KEYS, ap_point_name)

                    wait_el_xpath_click(self.driver,
                                        C_WLAN.PATH_SPINNER_SECURITY)
                    wait_el_xpath_click(self.driver, C_WLAN.PATH_WPA_SECURITY)
                    wait_el_xpath_click(self.driver,
                                        C_WLAN.PATH_CHECKBOX_PW_SHOW)
                    et_pw = wait_el_xpath(self.driver, C_WLAN.PATH_ET_PW)
                    action(et_pw, Commands.CLEAR)
                    action(et_pw, Commands.CLICK)

                    # password: 173925239
                    password_str = C_WLAN.AP_PASSWORD
                    for s in password_str:
                        self.driver.press_keycode(Keycode.get(self, s))
                    wait_el_xpath_click(self.driver, C_WLAN.PATH_BTN_SAVE)
                    sleep(2)
                    break
            else:
                action(ap_point, Commands.CLICK)
                wait_el_xpath_click(self.driver, C_WLAN.PATH_CHECKBOX_PW_SHOW)
                et_pw = wait_el_xpath(self.driver, C_WLAN.PATH_ET_PW)
                action(et_pw, Commands.CLICK)
                action(et_pw, Commands.CLEAR)
                # password: 173925239
                password_str = C_WLAN.AP_PASSWORD
                for s in password_str:
                    self.driver.press_keycode(Keycode.get(self, s))
                wait_el_xpath_click(self.driver, C_WLAN.PATH_BTN_CONNECT)
                sleep(1)
                break

        sleep(8)
        self.driver.back()
        sleep(5)
        wifi_status = wait_el_xpath(self.driver, C_WLAN.PATH_WLAN_STATUS)
        if value(wifi_status, Commands.TEXT) == ap_point_name:
            logging.info('{0}: WLAN connect succeed.'.format(prefix))
        else:
            logging.info('{0}: WLAN connect unsucceed.'.format(prefix))
            self.fail('{0}: WLAN connect unsucceed.'.format(prefix))
        sleep(2)
        logging.info('{0}: END'.format(prefix))