Skip to content

Commit

Permalink
New config property restart_driver_fail in [Common] section to restar…
Browse files Browse the repository at this point in the history
…t the driver when the test fails
  • Loading branch information
rgonalo committed Jan 11, 2017
1 parent 7e5ea87 commit 245c18e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ v1.2.0

| If it's false, the WebElement is searched whenever is needed (default value)
| If it's true, the WebElement is saved in PageElement to avoid searching for the same element multiple times. Useful
| in mobile testing when searching for an element can take a long time.
| in mobile testing when searching for an element can take a long time.
- Refactored reset_object method. Now it has an optional parameter with the driver_wrapper.
- Fix error downloading videos after failed tests
- System property 'Config_environment' is used to select config files, e.g., to read android-properties.cfg file:
Expand All @@ -21,12 +21,14 @@ v1.2.0
$ Config_environment=android nosetests web/tests/test_web.py
Behave user property 'env' is deprecated, use 'Config_environment' instead:
- Behave user property 'env' is deprecated, use 'Config_environment' instead:

.. code:: console
$ behave -D Config_environment=android
- Fix error in visual tests when excluding elements in a scrolled page
- New config property 'restart_driver_fail' in [Common] section to restart the driver when the test fails even though
the value of *reuse_driver* property is *true*

v1.1.3
------
Expand Down
4 changes: 3 additions & 1 deletion toolium/behave/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ def bdd_common_after_scenario(context_or_world, scenario, status):

# Close browser and stop driver if it must not be reused
reuse_driver = context_or_world.toolium_config.getboolean_optional('Driver', 'reuse_driver')
DriverWrappersPool.close_drivers_and_download_videos(scenario_file_name, test_passed, reuse_driver)
restart_driver_fail = context_or_world.toolium_config.getboolean_optional('Driver', 'restart_driver_fail')
maintain_default = reuse_driver and (test_passed or not restart_driver_fail)
DriverWrappersPool.close_drivers_and_download_videos(scenario_file_name, test_passed, maintain_default)

# Save test status to be updated later
context_or_world.global_status['test_passed'] = context_or_world.global_status[
Expand Down
1 change: 1 addition & 0 deletions toolium/test/conf/properties.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ phantomjs_driver_path:
# Driver options
implicitly_wait: 5
reuse_driver: false
restart_driver_fail: true
save_web_element: false
appium_app_strings: false

Expand Down
6 changes: 4 additions & 2 deletions toolium/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ def tearDown(self):
DriverWrappersPool.save_all_webdriver_logs(self.get_subclassmethod_name(), self._test_passed)

# Close browser and stop driver if it must not be reused
DriverWrappersPool.close_drivers_and_download_videos(test_name, self._test_passed, self.reuse_driver)
if not self.reuse_driver:
restart_driver_fail = self.driver_wrapper.config.getboolean_optional('Driver', 'restart_driver_fail')
maintain_default = self.reuse_driver and (self._test_passed or not restart_driver_fail)
DriverWrappersPool.close_drivers_and_download_videos(test_name, self._test_passed, maintain_default)
if not maintain_default:
SeleniumTestCase.driver = None

def assert_screenshot(self, element, filename, threshold=0, exclude_elements=[], driver_wrapper=None, force=False):
Expand Down

0 comments on commit 245c18e

Please sign in to comment.