def setUp(self): TnsRunTest.setUp(self) Sync.revert(app_name=self.app_name, change_set=self.ts_change, fail_safe=True) Sync.revert(app_name=self.app_name, change_set=self.xml_change, fail_safe=True) self.chrome = Chrome()
def setUp(self): TnsRunTest.setUp(self) self.chrome = Chrome()
def setUpClass(cls): TnsRunTest.setUpClass() NG.kill() NG.new(collection=None, project=cls.app_name) cls.chrome = Chrome()
def setUpClass(cls): cls.chrome = Chrome()
def setUp(self): self.chrome = Chrome()
def test(self, name, url, text, flavor): Log.info(text) retries = 1 original_name = name.replace("_", " ").encode("utf8") data = { "name": original_name, "ios": "False", "android": "False", "flavor": str(flavor), "timeout": "False", "slow": "False" } is_android_fail = True is_ios_fail = True while retries >= 0: # =====================Android RUN======================== if is_android_fail: self.chrome = Chrome() link, is_slow = PlaygroundMarketSamples.get_link( self.chrome, url) if link == "": Log.info('No Playground URL found in Android stage !!!') data["timeout"] = "True" data["slow"] = "True" retries -= 1 continue Log.info('Testing Android !!!') image_name = '{0}_{1}.png'.format(name.encode("utf8"), str(Platform.ANDROID)) Preview.run_url(url=link, device=self.emu) Log.info(' Waiting Android app to load...') time.sleep(10) PlaygroundMarketSamples.verify_device_is_connected( self.chrome, "Android SDK built") emulator_result = PlaygroundMarketSamples.get_error( self.chrome) is_android_fail = emulator_result > 0 android = str(not is_android_fail) data["android"] = android data["slow"] = str(is_slow) if is_android_fail: self.emu.get_screen( os.path.join(Settings.TEST_OUT_IMAGES, image_name)) self.chrome.kill() # =====================iOS RUN======================== if Settings.HOST_OS == OSType.OSX and is_ios_fail: image_name = '{0}_{1}.png'.format(name.encode("utf8"), str(Platform.IOS)) if self.is_ios_fail: Log.info(' Installing Preview app on iOS ...') Preview.install_preview_app_no_unpack( self.sim, Platform.IOS) self.chrome = Chrome() link, is_slow = PlaygroundMarketSamples.get_link( self.chrome, url) if link == "": Log.info('No Playground URL found in iOS stage !!!') data["timeout"] = "True" data["slow"] = "True" retries -= 1 continue Log.info('Testing iOS !!!') Preview.run_url(url=link, device=self.sim) if "test_0_" in self._testMethodName or "test_000_" in self._testMethodName: time.sleep(10) PlaygroundMarketSamples.close_popup(self.sim) Log.info(' Waiting iOS app to load...') Preview.dismiss_simulator_alert() time.sleep(10) PlaygroundMarketSamples.verify_device_is_connected( self.chrome, self.sim.name) Preview.dismiss_simulator_alert() if "test_0_" in self._testMethodName or "test_000_" in self._testMethodName: PlaygroundMarketSamples.close_popup(self.sim) PlaygroundMarketSamples.close_permissions_windows_ios( name, self.sim) simulator_result = PlaygroundMarketSamples.get_error( self.chrome) is_app_active = Preview.is_running_on_ios( self.sim, Settings.Packages.PREVIEW_APP_ID) self.is_ios_fail = simulator_result > 0 or not is_app_active is_ios_fail = self.is_ios_fail os.environ["is_ios_fail"] = str(self.is_ios_fail) if self.is_ios_fail: self.sim.get_screen( os.path.join(Settings.TEST_OUT_IMAGES, image_name)) ios = str(not self.is_ios_fail) data["ios"] = ios data["slow"] = str(is_slow) if self.is_ios_fail is False and is_android_fail is False: break retries -= 1 self.tearDown() Market.preserve_data(data)