From c70dfb7a8b43e8335b582244f839973058fc34ea Mon Sep 17 00:00:00 2001 From: BruceDai Date: Tue, 11 Oct 2016 14:33:23 +0800 Subject: [PATCH] Enable webdriver test on IoT Linux platform. (#141) --- testkit-lite | 5 +++++ testkitlite/capability/xw_iot.py | 3 +++ testkitlite/engines/test_executer.py | 16 +++++++++------- 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 testkitlite/capability/xw_iot.py diff --git a/testkit-lite b/testkit-lite index 07b0df6..23b8d9d 100755 --- a/testkit-lite +++ b/testkit-lite @@ -381,6 +381,9 @@ to resolve this issue" % (LOG_DIR) elif conn_opt['commodule'] == 'windowshttp': targetplatform = "xw_windows" os.environ['targetplatform'] = targetplatform + elif conn_opt['commodule'] == 'iot': + targetplatform = "xw_iot" + os.environ['targetplatform'] = targetplatform # process test environ if OPTIONS.test_env: @@ -406,6 +409,8 @@ to resolve this issue" % (LOG_DIR) webdriver_vars = initCapability('TEST_PKG_NAME', 'TEST_ACTIVITY_NAME') elif targetplatform.upper().find('WINDOW') >= 0: webdriver_vars = initCapability('TEST_PKG_NAME', 'DEVICE_ID') + elif targetplatform.upper().find('IOT') >= 0: + webdriver_vars = initCapability('DEVICE_ID', 'TEST_PKG_NAME') else: webdriver_vars = initCapability() os.environ['WEBDRIVER_VARS'] = json.dumps(webdriver_vars) diff --git a/testkitlite/capability/xw_iot.py b/testkitlite/capability/xw_iot.py new file mode 100644 index 0000000..5c0a481 --- /dev/null +++ b/testkitlite/capability/xw_iot.py @@ -0,0 +1,3 @@ +def initCapability(device_id, test_suite_name): + capability = {'xwalkOptions': {'binary': "", "iotPackage": test_suite_name}} + return {'webdriver_url':"http://%s:9515" % device_id, 'desired_capabilities': capability} diff --git a/testkitlite/engines/test_executer.py b/testkitlite/engines/test_executer.py index f5a1a8b..7767716 100644 --- a/testkitlite/engines/test_executer.py +++ b/testkitlite/engines/test_executer.py @@ -91,7 +91,7 @@ def __updateTestPrefix(self): if url_components.scheme == 'http': self.test_prefix = '%s://%s/' % (url_components.scheme, url_components.netloc) - elif self.target_platform.upper().find('TIZEN') >=0: + elif self.target_platform.upper().find('TIZEN') >=0 or self.target_platform.upper().find('IOT') >=0: url_components = urlparse(current_url) self.test_prefix = '%s://%s/' % (url_components.scheme, url_components.netloc) @@ -125,6 +125,14 @@ def __initWebDriver(self): self.test_prefix = driver_env['test_prefix'] self.wd_url = driver_env['webdriver_url'] self.web_driver = WebDriver(self.wd_url, capa) + elif self.target_platform.upper().find('IOT') >= 0: + device_ip = str(self.device_id.split('@')[1]) + driver_env = initCapability(str(device_ip), self.appid) + capa = driver_env['desired_capabilities'] + self.wd_url = driver_env['webdriver_url'] + self.web_driver = WebDriver(self.wd_url, capa) + time.sleep(3) + self.__updateTestPrefix() elif self.target_platform.upper().find('ANDROID') >= 0 and self.launcher != "CordovaLauncher": test_app, test_ext = self.appid.split('/') test_ext = test_ext.strip('.').replace('Activity', '') @@ -322,13 +330,10 @@ def __runRefTests(self, haha=None, kkkk=None): except Exception, e: i_case_timeout = DEFAULT_TIMEOUT - self.__initWebDriver() i_page_url = '%s%s' % (self.test_prefix, i_case['entry']) try: - self.web_driver.set_page_load_timeout(i_case_timeout) self.web_driver.get(i_page_url) - self.web_driver.implicitly_wait(i_case['onload_delay']) except Exception, e: i_case['result'] = STR_BLOCK self.TE_LOG.info( @@ -362,12 +367,9 @@ def __runRefTests(self, haha=None, kkkk=None): except Exception, e: i_refer_case_timeout = DEFAULT_TIMEOUT - self.__initWebDriver() i_ref_page_url = '%s%s' % (self.test_prefix, i_case['refer_entry']) try: - self.web_driver.set_page_load_timeout(i_refer_case_timeout) self.web_driver.get(i_ref_page_url) - self.web_driver.implicitly_wait(i_case['onload_delay']) except Exception, e: i_case['result'] = STR_BLOCK self.TE_LOG.info(