Skip to content

Commit

Permalink
[qalab] extract vars_names to move JSON config
Browse files Browse the repository at this point in the history
+ issue related #33
  • Loading branch information
crypto netzulo committed Jan 5, 2018
1 parent 29c58c5 commit fb17146
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 51 deletions.
6 changes: 3 additions & 3 deletions qalab/configs/appium.node.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
"platformVersion": "6.0",
"deviceName": "qa-tablet-nexus10",
"orientation": "LANDSCAPE",
"app": "qalab/apks/selendroid-test-app-0.17.0.apk"
"app": "qalab/apks/Art_of_Conquest_AoC_v1.15.6.apk"
}
],
"configuration": {
"cleanUpCycle": 2000,
"cleanUpCycle": 3000,
"timeout": -1,
"url": "http://localhost:4723/wd/hub",
"host": "localhost",
"port": 4723,
"maxSession": 1,
"register": true,
"registerCycle": 5000,
"registerCycle": 3000,
"hubPort": 11000,
"hubHost": "localhost"
}
Expand Down
1 change: 1 addition & 0 deletions qalab/configs/selenium.node.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 25,
"host": "localhost",
"port": 11001,
"register": true,
"registerCycle": 5000,
Expand Down
77 changes: 77 additions & 0 deletions qalab/configs/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
"""TODO: doc module"""


# SETTINGS start
PATH_CONFIG = 'qalab/configs'
PATH_DRIVERS_MODULE = 'modules/qadrivers/'
PATH_SERVER_DRIVERS = 'qalab/drivers'
PATH_APKS = 'qalab/apks'
WEBDRIVER_ENV_VARS = [
"-Dwebdriver.chrome.driver=",
"-Dwebdriver.gecko.driver=",
"-Dphantomjs.binary.path=",
"-Dwebdriver.ie.driver=",
"-Dwebdriver.edge.driver=",
"-Dwebdriver.opera.driver="
]
DRIVERS_NAMES = [
"chromedriver_32.exe",
"chromedriver_64.exe",
"chromedriver_32",
"chromedriver_64",
"firefoxdriver_32.exe",
"firefoxdriver_64.exe",
"firefoxdriver_32",
"firefoxdriver_64",
"phantomjsdriver_32.exe",
"phantomjsdriver_64.exe",
"phantomjsdriver_32",
"phantomjsdriver_64",
"iexplorerdriver_32.exe",
"iexplorerdriver_64.exe",
"edgedriver_32.exe",
"edgedriver_64.exe",
"operadriver_32.exe",
"operadriver_64.exe",
"operadriver_32",
"operadriver_64",
]
MSG_UNKOWN_COMMAND = "Unknown command : {}"
### COMMON
# {path}/{args.server_driver}.{args.mode}.json
DRIVER_CONFIG_PATH = "{}/{}.{}.json"
# {path}/{args.server_driver}.{args.mode}.example.json
DRIVER_CONFIG_PATH_EXAMPLE = "{}/{}.{}.example.json"
### SELENIUM
SELENIUM_VERSION = "3.5"
SELENIUM_VERSION_BUILD = "3.5.3"
SELENIUM_JAR_NAME = "selenium-server-standalone-{}.jar".format(
SELENIUM_VERSION_BUILD)
SELENIUM_URL = "https://selenium-release.storage.googleapis.com/{}/{}".format(
SELENIUM_VERSION, SELENIUM_JAR_NAME)

### SELENDROID
# Selendroid , TODO: just for mode node
SELENDROID_PORT = 12000
SELENDROID_SELENDROID_VERSION = '0.17.0'
SELENDROID_JAR = 'selendroid-standalone-{}-with-dependencies.jar'.format(
SELENDROID_SELENDROID_VERSION)
SELENDROID_URL = '{}/{}/{}'.format(
'https://github.com/selendroid/selendroid/releases/download',
SELENDROID_SELENDROID_VERSION,
SELENDROID_JAR)
# Selendroid plugin, TODO: just for mode node
SELENDROID_PLUGIN_JAR = 'selendroid-grid-plugin-{}.jar'.format(
SELENDROID_SELENDROID_VERSION)
SELENDROID_PLUGIN_URL = '{}/{}/{}'.format(
'http://search.maven.org/remotecontent?filepath=io/selendroid/selendroid-grid-plugin',
SELENDROID_SELENDROID_VERSION,
SELENDROID_JAR)
# Selenium, TODO: just for mode hub
SELENDROID_SELENIUM_VERSION = "3.5.3"
SELENDROID_SELENIUM_JAR = "selenium-server-standalone-{}.jar".format(
SELENDROID_SELENIUM_VERSION)
SELENDROID_SELENIUM_URL = "https://selenium-release.storage.googleapis.com/3.5/{}".format(
SELENDROID_SELENIUM_JAR)
# SETTINGS end
Empty file added qalab/core/__init__.py
Empty file.
19 changes: 19 additions & 0 deletions qalab/core/server_driver__selendroid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# -*- coding: utf-8 -*-
"""TODO: doc module"""


from qalab.core.server_driver_base import ServerDriverBase


class ServerDriverSelendroid(ServerDriverBase):
"""TODO: doc class"""

_server_driver = 'selendroid'

def __init__(self, mode):
"""TODO: doc method"""
super(ServerDriverSelendroid, self).__init__(mode)

def install(self):
self._configure(self._server_driver)
19 changes: 19 additions & 0 deletions qalab/core/server_driver_appium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# -*- coding: utf-8 -*-
"""TODO: doc module"""


from qalab.core.server_driver_base import ServerDriverBase


class ServerDriverAppium(ServerDriverBase):
"""TODO: doc class"""

_server_driver = 'appium'

def __init__(self):
"""TODO: doc method"""
super(ServerDriverAppium, self).__init__()

def install(self):
self._configure(self._server_driver)
53 changes: 53 additions & 0 deletions qalab/core/server_driver_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

# -*- coding: utf-8 -*-
"""TODO: doc module"""


import qalab.configs.settings as SETTINGS
import shutil


class ServerDriverBase(object):
"""TODO: doc class"""

_mode = None
_config_src = None
_config_dst = None
_server_driver = 'base'


def __init__(self, mode):
"""TODO: doc method"""
if mode is None:
raise Exception("param 'mode' can't be None")
if mode not in ['hub', 'node']:
raise Exception('Select valid mode, values are: [hub, node]')
self._mode = mode
_config_path_example = SETTINGS.DRIVER_CONFIG_PATH_EXAMPLE
_config_path = SETTINGS.DRIVER_CONFIG_PATH

def _configure(self, server_driver):
"""
Just copy settings from example file
from: {server_driver}.{args.mode}.example.json
to: {server_driver}.{args.mode}.json
"""
if server_driver not in ['selenium', 'selendroid', 'appium']:
raise Exception(
'Select valid mode, values are: [selenium, selendroid, appium]'
)
self._config_path_example = self._config_path_example.format(
SETTINGS.PATH_CONFIG, server_driver, self._mode)
self._config_path = self._config_path.format(
SETTINGS.PATH_CONFIG, server_driver, self._mode)
shutil.copy2(
self._config_path_example,
self._config_path)

def install(self):
"""Installation process"""
raise NotImplementedError('need to be overrided on inherit classes')

def start(self):
"""Installation process"""
raise NotImplementedError('need to be overrided on inherit classes')
47 changes: 47 additions & 0 deletions qalab/core/server_driver_selenium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

# -*- coding: utf-8 -*-
"""TODO: doc module"""


from qalab.core.server_driver_base import ServerDriverBase
import qalab.configs.settings as SETTINGS


class ServerDriverSelenium(ServerDriverBase):
"""TODO: doc class"""

_server_driver = 'selenium'
_drivers_abspath = None


def __init__(self, mode):
"""TODO: doc method"""
super(ServerDriverSelenium, self).__init__(mode)
self._drivers_abspath = self.get_abspaths()

def install(self):
self._configure(self._server_driver)

def get_abspaths(self):
"""TODO: doc method"""
drivers_abspath = []
for driver_name in SETTINGS.DRIVERS_NAMES:
webdriver_var_name = None
if driver_name.startswith("chrome"):
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[0]
if driver_name.startswith("firefox"):
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[1]
if driver_name.startswith("phantomjs"):
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[2]
if driver_name.startswith("iexplorer"):
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[3]
if driver_name.startswith("edge"):
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[4]
if driver_name.startswith("opera"):
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[5]
# Get absolute path for driver_name
drivers_abspath.append("{}{}{}".format(
webdriver_var_name,
SETTINGS.PATH_DRIVERS_MODULE,
driver_name))
return drivers_abspath
Loading

0 comments on commit fb17146

Please sign in to comment.