Skip to content

Commit

Permalink
Merge pull request #31 from Telefonica/release/1.1.0
Browse files Browse the repository at this point in the history
Release/1.1.0
  • Loading branch information
rgonalo committed Jun 3, 2016
2 parents 9b8db2c + a31ee21 commit f29446f
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 12 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Toolium Changelog
v1.1.0
------

*In development*
*Release date: 2016-06-03*

- New MobilePageObject class to test Android and iOS apps with the same base page object
- New MobilePageObject class to test Android and iOS apps with the same base page objects
- Fix visual report links in Windows
- Add @no_reset_app, @reset_app and @full_reset_app behave tags to configure Appium reset capabilities for one scenario
- Add @android_only and @ios_only behave tags to exclude one scenario from iOS or Android executions
Expand All @@ -16,7 +16,6 @@ v1.1.0
$ behave -D env=android
v1.0.1
------

Expand Down
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ to use the library to test web, Android or iOS applications, in different scenar
$ git clone [email protected]:Telefonica/toolium-examples.git
$ cd toolium-examples
$ pip install -r requirements.txt
$ nosetests
Contributing
------------
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.0-dev
v1.1.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_long_description():
keywords=['selenium', 'appium', 'webdriver', 'web automation', 'mobile automation', 'page object',
'visual testing', 'bdd', 'lettuce', 'behave'],
classifiers=[
'Development Status :: 3 - Alpha',
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Other Audience',
'License :: OSI Approved :: Apache Software License',
Expand Down
6 changes: 1 addition & 5 deletions toolium/behave/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
limitations under the License.
"""

import inspect
import logging
import os
import re
Expand All @@ -37,8 +36,7 @@ def before_all(context):

# By default config directory is located in environment path
if not context.config_files.config_directory:
environment_path = os.path.dirname(os.path.realpath(inspect.getouterframes(inspect.currentframe())[1][1]))
context.config_files.set_config_directory(os.path.join(environment_path, 'conf'))
context.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())

# Get 'env' property from user input (e.g. -D env=ios)
env = context.config.userdata.get('env')
Expand Down Expand Up @@ -112,8 +110,6 @@ def create_and_configure_wrapper(context_or_world):
context_or_world.utils = context_or_world.driver_wrapper.utils

# Configure wrapper
if not hasattr(context_or_world, 'config_files'):
context_or_world.config_files = ConfigFiles()
context_or_world.driver_wrapper.configure(True, context_or_world.config_files)

# Override properties with behave userdata properties
Expand Down
10 changes: 10 additions & 0 deletions toolium/driver_wrappers_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""

import datetime
import inspect
import logging
import os

Expand Down Expand Up @@ -174,6 +175,15 @@ def configure_common_directories(cls, tc_config_files):
if not os.path.exists(cls.output_directory):
os.makedirs(cls.output_directory)

@staticmethod
def get_default_config_directory():
"""Return default config directory, based in the actual test path
:returns: default config directory
"""
test_path = os.path.dirname(os.path.realpath(inspect.getouterframes(inspect.currentframe())[2][1]))
return os.path.join(test_path, 'conf')

@staticmethod
def _find_parent_directory(directory, filename):
"""Find a directory in parent tree with a specific filename
Expand Down
9 changes: 9 additions & 0 deletions toolium/lettuce/terrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@
from lettuce import world

from toolium.behave.environment import bdd_common_before_scenario, bdd_common_after_scenario, bdd_common_after_all
from toolium.config_files import ConfigFiles
from toolium.driver_wrapper import DriverWrappersPool


def setup_driver(scenario):
"""Scenario initialization
:param scenario: running scenario
"""
if not hasattr(world, 'config_files'):
world.config_files = ConfigFiles()

# By default config directory is located in terrain path
if not world.config_files.config_directory:
world.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())

bdd_common_before_scenario(world, scenario)


Expand Down
14 changes: 13 additions & 1 deletion toolium/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def tearDownClass(cls):
def setUp(self):
# Configure logger and properties
if not isinstance(self, SeleniumTestCase):
# By default config directory is located in test path
if not self.config_files.config_directory:
self.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())

self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
self.driver_wrapper.configure(False, self.config_files)
# Get config and logger instances
Expand Down Expand Up @@ -108,6 +112,10 @@ def setUp(self):
# Get default driver wrapper
self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
if not SeleniumTestCase.driver:
# By default config directory is located in test path
if not self.config_files.config_directory:
self.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())

# Create driver
self.driver_wrapper.configure(True, self.config_files)
self.driver_wrapper.connect()
Expand Down Expand Up @@ -187,8 +195,12 @@ def driver(self):
:returns: Appium driver
:rtype: appium.webdriver.webdriver.WebDriver
"""
return super(AppiumTestCase, self).driver
return SeleniumTestCase.driver

def setUp(self):
if not SeleniumTestCase.driver and not self.config_files.config_directory:
# By default config directory is located in test path
self.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())

super(AppiumTestCase, self).setUp()
AppiumTestCase.app_strings = self.driver_wrapper.app_strings
14 changes: 14 additions & 0 deletions toolium/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,17 @@ def get_web_element(self, element):
else:
web_element = None
return web_element

def get_first_webview_context(self):
"""Return the first WEBVIEW context or raise an exception if it is not found
:returns: first WEBVIEW context
"""
for context in self.driver_wrapper.driver.contexts:
if context.startswith('WEBVIEW'):
return context
raise Exception('No WEBVIEW context has been found')

def switch_to_first_webview_context(self):
"""Switch to the first WEBVIEW context"""
self.driver_wrapper.driver.switch_to.context(self.get_first_webview_context())

0 comments on commit f29446f

Please sign in to comment.