def startApp(): # click ok in youtube g_common_obj.launch_app_from_home_sc("YouTube") d = g_common_obj.get_device() time.sleep(5) d.watcher("SKIP_UPDATE").\ when(resourceId="com.google.android.youtube:id/later_button")\ .click(resourceId="com.google.android.youtube:id/later_button") if d(text="What to Watch").exists: g_common_obj.back_home() return for _ in range(60): if d(text="What to Watch").exists and not d(text="OK").exists: break if d(text="OK").exists: d(text="OK").click.wait() if d(text="Skip").exists: d(text="Skip").click.wait() if d(text="Retry").exists: d(text="Retry").click.wait() time.sleep(2) d.press.back() if d(description="YouTube").exists: d(description="YouTube").click.wait() time.sleep(2) if d(text="Skip").exists: d(text="Skip").click.wait() d.watcher("SKIP_UPDATE").remove() g_common_obj.back_home()
def basic_test(self): """ Basic funtion test """ g_common_obj.launch_app_from_home_sc("Slides") if not self._locator.btn_add.exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d( packageName="com.google.android.apps.docs.editors.slides" ).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/slides.png") self.d.press.back() return self._locator.btn_add.click() time.sleep(10) if not self._locator.btn_overflow.exists: print "[WARNING:UI is changed! Just test add function]" assert self.d( packageName="com.google.android.apps.docs.editors.slides" ).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/slides.png") self.d.press.back() return assert self._locator.btn_overflow.exists g_common_obj.back_home()
def launch_app(self, appname, packagename): """ @summary: launch app """ g_common_obj.launch_app_from_home_sc(appname) time.sleep(2) assert_equals(self.d(packageName=packagename).exists, True)
def youtube_first_movie_play(self, timeout=120): """ @summayr: play the first movie in youtube movie list @return: None """ g_common_obj.launch_app_from_home_sc("YouTube") if not self._locator.btn_youtube_firstmovie.exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d(packageName=self.cfg.get("package_name")).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/youtube.png") self.d.press.back() return while not self._locator.btn_youtube_firstmovie.exists: time.sleep(10) timeout -= 10 if timeout <= 0: break assert self._locator.btn_youtube_firstmovie.exists, \ "ERROR:There is no movie here!" self._locator.btn_youtube_firstmovie.click() time.sleep(5) assert self._locator.btn_player.exists, \ "No player coming out" time.sleep(10) self.youtube_quit_by_backkey()
def startAppMusic(): d = g_common_obj.get_device() g_common_obj.launch_app_from_home_sc("Play Music") time.sleep(10) for _ in range(30): time.sleep(2) if not d(resourceId="com.google.android.music:id/tutorial_logo" ).exists: break assert not d( resourceId="com.google.android.music:id/tutorial_logo").exists if d(text="Skip").exists: d(text="Skip").click.wait() if d(text="Use Standard").exists: d(text="Use Standard").click.wait() if d(text="Done").exists: d(text="Done").click.wait() if d(resourceId="com.google.android.music:id/play_drawer_list").exists: d.press.back() if d(text="Got it").exists: d(text="Got it").click.wait() g_common_obj.launch_app_am( "com.google.android.music", "com.android.music.activitymanagement.TopLevelActivity") time.sleep(5) g_common_obj.back_home()
def startApp(self): """ Skip Email first launch screen """ g_common_obj.launch_app_from_home_sc("Email") assert self.d(packageName = EmailImpl.mail_pkg_name).wait.exists() if self.d(textContains="Getting").exists: self.d(textContains="Getting").wait.gone(timeout=600000) assert not self.d(textContains="Getting").exists, \ "ERROR: SYNC for more than 10 mins" if self.d(resourceId="com.android.email:id/account_email").exists: self.d(resourceId="com.android.email:id/account_email").click() g_common_obj.adb_cmd_capture_msg( "input text " + self.cfg.get("email_account")) time.sleep(2) self.d(resourceId="com.android.email:id/next").click() self.d(resourceId="com.android.email:id/regular_password").\ wait.exists() self.d(resourceId="com.android.email:id/regular_password").click() time.sleep(2) g_common_obj.adb_cmd_capture_msg( "input text " + self.cfg.get("email_pwd")) time.sleep(2) self.d(resourceId="com.android.email:id/next").click() assert self.d(text="Account options").wait.exists(timeout=60000) for _ in (0, 10): if self.d( resourceId="com.android.email:id/next")\ .wait.exists(timeout=60000): self.d(resourceId="com.android.email:id/next").click() else: break assert self.d(text="Inbox").wait.exists(timeout=60000) g_common_obj.back_home()
def launch_from_settings(self): """Launch Settings and enter into Airplane mode Setting UI""" print "[INFO]: Launch airplane mode from Settings" self.d.press.home() g_common_obj.launch_app_from_home_sc("Settings") self._locator.setting_more.click.wait() assert self._locator.btn_airplane.exists, True
def launch_by_home(self): """Launch browser by home""" print "[INFO] Launch browser by home" self.d.press.home() g_common_obj.launch_app_from_home_sc("CM Browser", "Apps") if self._locator.browser_logo.exists: self.d.press.back() assert self._locator.package_name.exists, True
def enter_camera_from_app_icon(self): """ @summary: enter camera from Apps gallery """ self.d.press.home() g_common_obj.launch_app_from_home_sc("Camera") time.sleep(2) self.judge_if_camera_crash()
def launch_item_setting_from_app_gallery(self, itemtext): g_common_obj.launch_app_from_home_sc("Settings", "Apps") timeout = 50 begin = time.time() while not self.d(text=itemtext).exists: self.d(scrollable=True).scroll.vert() assert (time.time() - begin > timeout) if self.d(text=itemtext).exists: break self.d(text=itemtext).click.wait()
def launch_from_app_gallery(self): """ launch Google Map from UI """ self.d.watcher("SKILL_WELCOME").\ when(textMatches="Welcome!").press("back") g_common_obj.launch_app_from_home_sc(LLTUDE.app_name, "Apps", None) time.sleep(3) if not self.focus_window(self.pkg_name): self.install() g_common_obj.launch_app_from_home_sc(LLTUDE.app_name, "Apps", None) time.sleep(3) assert self.wait_exist(self.locator.btn_lltitle, 60), "Launch failed!"
def launch_from_settings(self): """Launch Wi-Fi from Settings""" print "[INFO] Launch Wi-Fi from Settings" msg_fail = "[FAILURE] Launch Wi-Fi Setttings fail" self.d.press.home() g_common_obj.launch_app_from_home_sc("Settings") if self.d(scrollable=True).exists: self.d(scrollable=True).scroll.to(textMatches="Wi.*Fi") time.sleep(1) self._locator.wifi_settings.click() assert self._locator.btn_more_options.exists, msg_fail
def startApp(): """ Skip Google Plus first launch screen """ d = g_common_obj.get_device() g_common_obj.launch_app_from_home_sc("Google+") time.sleep(10) while d(resourceId="com.google.android.apps.plus:id/warm_welcome_button" ).exists: d(resourceId="com.google.android.apps.plus:id/warm_welcome_button" ).click() d.wait.update() g_common_obj.back_home()
def switch_camera_preview(self, switch_times=24): """ perform unexist menu press to switch front camera and rear camera in APIDemos--->Graphics--->CameraPreview """ self.unlock(self) g_common_obj.launch_app_from_home_sc("API Demos") self.device(text="Graphics").click() self.device(text="CameraPreview", className="android.widget.TextView").click() # here you can change switch times for d in xrange(switch_times): if self.device.press.menu(): True assert self.device(text="Switch Camera").exists is True self.device(text="Switch Camera").click()
def startApp(): """ Skip Gmail first launch screen """ g_common_obj.launch_app_from_home_sc("Gmail") time.sleep(10) d = g_common_obj.get_device() while d( resourceId="com.google.android.gm:id/welcome_tour_got_it").exists: d( resourceId="com.google.android.gm:id/welcome_tour_got_it").click() d.wait.update() while d(resourceId="com.google.android.gm:id/action_done").exists: d(resourceId="com.google.android.gm:id/action_done").click() d.wait.update() g_common_obj.back_home()
def testInteractingWithAppDuringGOTA(self): """ This test case is to test interacting app during gota Test Case Precondition: Test Case Step: 1. cpen chrome when gota downloading Expect Result: 1. app open successfully 3. gota successfully The real implementation will be in gota_Impl class. """ print "[RunTest]: %s" % self.__str__() g_common_obj.launch_app_from_home_sc("Chrome")
def launch_from_app_gallery(): """ launch ES File Explorer from UI """ g_common_obj.launch_app_from_home_sc(\ ESFileExplorer.app_name, "Apps", "New") time.sleep(6)
def init_chrome(self): # init chrome's two options g_common_obj.launch_app_from_home_sc("Chrome") time.sleep(5) while self.d(text="Accept & continue").exists: self.d(text="Accept & continue").click.wait() if self.d(text="Done").exists: self.d(text="Done").click.wait() if self.d(text="No thanks").exists: self.d(text="No thanks").click.wait() if self.d(text="No Thanks").exists: self.d(text="No Thanks").click.wait() if self.d(description="More options").exists: self.d(description="More options").click.wait() if self.d(text="Cancel").exists: self.d(text="Cancel").click.wait() if self.d(resourceId="com.android.chrome:id/menu_button").exists: self.d(resourceId="com.android.chrome:id/menu_button").click.wait() if self.d(text="Settings").exists: self.d(text="Settings").click.wait() if self.d(text="Sign in to Chrome").exists: self.d(text="Sign in to Chrome").click.wait() if self.d(text="Add a Google Account").exists: self.d(text="Cancel").click.wait() else: self.d(text="Sign in").click.wait() if self.check_if_app_not_first_init("Chrome") is False: self.d.press.recent() self.d(text="Chrome", resourceId="com.android.systemui:id/activity_description").click.wait() if self.d(text="Basics").down(resourceId="com.android.chrome:id/header_title", textContains="@gmail.com") != None: self.d(text="Basics").down(resourceId="com.android.chrome:id/header_title", textContains="@gmail.com").click.wait() if self.d(textContains="Auto sign").right(resourceId="android:id/checkbox").checked: self.d(textContains="Auto sign").right(resourceId="android:id/checkbox").click() else: self.d.press.recent() self.d(text="Chrome", resourceId="com.android.systemui:id/activity_description").click.wait() pass if self.d(resourceId="com.android.chrome:id/menu_button").exists: self.d(resourceId="com.android.chrome:id/menu_button").click.wait() self.d(text="Privacy").click.wait() if self.d(textContains="Navigation").right(resourceId="android:id/checkbox").checked: self.d(textContains="Navigation").right(resourceId="android:id/checkbox").click.wait() if self.d(textContains="Search and").right(resourceId="android:id/checkbox").checked: self.d(textContains="Search and").right(resourceId="android:id/checkbox").click.wait() if self.d(textContains="Usage and crash reports").right(resourceId="android:id/checkbox").checked: self.d(textContains="Usage and crash reports").right(resourceId="android:id/checkbox").click.wait() if self.d(text="CLEAR BROWSING DATA...").exists: self.d(text="CLEAR BROWSING DATA...").click.wait() # if self.d(text="Clear browsing data").exists: if self.d(text="Clear browsing history").exists: if not self.d(text="Clear browsing history").checked: self.d(text="Clear browsing history").click.wait() if self.d(text="Clear the cache").exists: if not self.d(text="Clear the cache").checked: self.d(text="Clear the cache").click.wait() if self.d(textContains="Clear cookies").exists: if not self.d(textContains="Clear cookies").checked: self.d(textContains="Clear cookies").click.wait() if self.d(text="Clear").exists: self.d(text="Clear").click.wait() if self.d(text="Accept").exists: self.d(text="Accept").click.wait() self.d.press.back() self.d.press.back() url = "http://www.youtube.com/watch?v=OYotwvVzBm4" for i in range(3): self.d(resourceId="com.android.chrome:id/url_bar").clear_text() if self.d(resourceId="com.android.chrome:id/website_settings_connection_message").exists: self.d.press.back() self.d(resourceId="com.android.chrome:id/url_bar").set_text(url) self.d.press.enter() time.sleep(2) for i in range(10): if self.d(resourceId="com.android.chrome:id/url_bar", text="m.youtube.com").exists: g_common_obj.adb_cmd("am force-stop com.android.chrome") return if self.d(textStartsWith="Open with", resourceId="android:id/title").exists: self.d(textContains="Chrome").click.wait() if self.d(text="Always").exists: self.d(text="Always").click.wait() if self.d(description="Web View").exists: self.d.press.back() time.sleep(5) if self.d(text="OK").exists: self.d(text="OK").click.wait() g_common_obj.adb_cmd("am force-stop com.android.chrome") return time.sleep(3) g_common_obj.adb_cmd("am force-stop com.android.chrome")