Skip to content

Commit

Permalink
Merge pull request #67 from salsita/browserstack-appium
Browse files Browse the repository at this point in the history
new mobile capabilities for BS
  • Loading branch information
gvozdeva-ira committed Jan 10, 2018
2 parents 9650b71 + b096ff8 commit 2044223
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
22 changes: 12 additions & 10 deletions shishito/reporting/junithtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,18 @@ def _append_screenshot(self, name, log):
log.append(html.h3('Screenshots'))

# Following works only for manually captured images.
related_images = glob.glob(os.path.join(self.project_root, 'screenshots', browser_name + '_' + name + '_*.png'))

for image_path in related_images:
self.used_screens.append(image_path)
# use relative path in img src
source = image_path.replace(self.project_root, '.')
log.append(source)
log.append(html.br())
log.append(html.img(src=source))
log.append(html.br())
images_saved = os.path.join(self.project_root, 'screenshots')
if os.path.isdir(images_saved):
for file in os.listdir(images_saved):
image_path = os.path.join(images_saved, file)
if name in image_path:
self.used_screens.append(image_path)
# use relative path in img src
source = image_path.replace(self.project_root, '.')
log.append(source)
log.append(html.br())
log.append(html.img(src=source))
log.append(html.br())

def _append_link_to_debug_event(self, name, log):
name = re.sub('[^A-Za-z0-9_.]+', '_', name)
Expand Down
16 changes: 11 additions & 5 deletions shishito/runtime/environment/appium_bs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def call_browser(self, config_section):

# get browser capabilities
capabilities = self.get_capabilities(config_section)
saucelabs = self.shishito_support.get_opt('saucelabs')
browserstack = self.shishito_support.get_opt('browserstack')

if browserstack:
Expand All @@ -45,15 +44,23 @@ def get_capabilities(self, config_section):
"""

get_opt = self.shishito_support.get_opt
return {

capabilities= {
'os': get_opt(config_section, 'os'),
'os_version': get_opt(config_section, 'os_version'),
'device': get_opt(config_section, 'device'),
'app': get_opt('app') or get_opt(config_section, 'app'),
'autoAcceptAlerts': True if get_opt(config_section, 'autoAcceptAlerts').lower() == 'true' else False,
'name': self.get_test_name() + time.strftime('_%Y-%m-%d'),
'browserstack.debug': get_opt('browserstack_debug').lower() or False,
'browserstack.appium_version': get_opt(config_section, 'browserstack.appium_version') or '1.7.0'
'browserstack.appium_version': get_opt(config_section, 'browserstack.appium_version') or '1.7.0',
'deviceOrientation': get_opt(config_section, 'deviceOrientation') or 'portrait'
}
if(get_opt(config_section, 'os')=='android'):
capabilities['autoGrantPermissions']= get_opt(config_section, 'autoGrantPermissions') or False
if(get_opt(config_section, 'os')=='ios'):
capabilities['autoAcceptAlerts'] = get_opt(config_section, 'autoAcceptAlerts').lower() or False
return capabilities


def get_pytest_arguments(self, config_section):
""" Get environment specific arguments for pytest.
Expand All @@ -65,7 +72,6 @@ def get_pytest_arguments(self, config_section):
pytest_args = {
'--os_version': '--os_version=%s' % self.shishito_support.get_opt(config_section, 'os_version'),
'--device': '--device=%s' % self.shishito_support.get_opt(config_section, 'device'),
'--autoAcceptAlerts': '--autoAcceptAlerts=%s' % self.shishito_support.get_opt(config_section, 'autoAcceptAlerts'),
'--app': '--app=%s' % (self.shishito_support.get_opt('app') or self.shishito_support.get_opt(config_section, 'app'))
}
browserstack = self.shishito_support.get_opt('browserstack')
Expand Down
9 changes: 4 additions & 5 deletions shishito/runtime/platform/shishito_control_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ def stop_test(self, test_info, debug_events=None):

# Capture screenshot and debug info from driver(s)
for driver in self.drivers:
browser_name = driver.name
if browser_name == '':
if(self.shishito_support.test_platform == 'mobile'):
browser_name = 'appium'
else:
browser_name = driver.name
file_name = browser_name + '_' + test_name

ts = SeleniumTest(driver)
ts.save_screenshot(file_name)

ts.save_screenshot(name=file_name)

#Save debug info to file
if debug_events is not None:
Expand Down

0 comments on commit 2044223

Please sign in to comment.