Skip to content

Commit

Permalink
Enable webdriver test on IoT Linux platform. (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceDai authored Oct 11, 2016
1 parent 83526dc commit c70dfb7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions testkit-lite
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions testkitlite/capability/xw_iot.py
Original file line number Diff line number Diff line change
@@ -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}
16 changes: 9 additions & 7 deletions testkitlite/engines/test_executer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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', '')
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c70dfb7

Please sign in to comment.