Skip to content

Commit

Permalink
Merge pull request #124 from Telefonica/fix/platform
Browse files Browse the repository at this point in the history
Fix key error getting platform in Firefox and check selenoid capabili…
  • Loading branch information
rgonalo committed Mar 18, 2019
2 parents 502111e + ae6167c commit a17696c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ v1.5.1

*Release date: WIP*

- Download Selenoid video and logs files only in Linux nodes
- Download Selenoid video and logs files only in linux nodes if video or logs are enabled
- Add a sleep between Selenoid retries when downloading files

v1.5.0
Expand Down
12 changes: 12 additions & 0 deletions toolium/driver_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,15 @@ def should_reuse_driver(self, scope, test_passed, context=None):
and context.reuse_driver_from_tags)
return (((reuse_driver and scope == 'function') or (reuse_driver_session and scope != 'session'))
and (test_passed or not restart_driver_after_failure))

def get_driver_platform(self):
"""
Get driver platform where tests are running
:return: platform name
"""
platform = ''
if 'platform' in self.driver.desired_capabilities:
platform = self.driver.desired_capabilities['platform']
elif 'platformName' in self.driver.desired_capabilities:
platform = self.driver.desired_capabilities['platformName']
return platform
10 changes: 6 additions & 4 deletions toolium/selenoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ def download_session_video(self, scenario_name, timeout=5):
:param scenario_name: scenario name
:param timeout: threshold until the video file is downloaded
"""
# Download video only in linux nodes
if self.driver_wrapper.driver.desired_capabilities['platform'].lower() != 'linux':
# Download video only in linux nodes with video enabled
if (self.driver_wrapper.get_driver_platform().lower() != 'linux' or
not self.driver_wrapper.config.getboolean_optional('Capabilities', 'enableVideo')):
return

path_file = os.path.join(self.videos_directory, '%s.%s' % (scenario_name, MP4_EXTENSION))
Expand All @@ -161,8 +162,9 @@ def download_session_log(self, scenario_name, timeout=5):
:param scenario_name: scenario name
:param timeout: threshold until the video file is downloaded
"""
# Download logs only in linux nodes
if self.driver_wrapper.driver.desired_capabilities['platform'].lower() != 'linux':
# Download logs only in linux nodes with logs enabled
if (self.driver_wrapper.get_driver_platform().lower() != 'linux' or
not self.driver_wrapper.config.getboolean_optional('Capabilities', 'enableLog')):
return

path_file = os.path.join(self.logs_directory, '%s_ggr.%s' % (scenario_name, LOG_EXTENSION))
Expand Down

0 comments on commit a17696c

Please sign in to comment.