diff --git a/README_APPIUM_AND_SELENIUM.md b/README_APPIUM_AND_SELENIUM.md index a7678a0..b8a191b 100644 --- a/README_APPIUM_AND_SELENIUM.md +++ b/README_APPIUM_AND_SELENIUM.md @@ -24,6 +24,7 @@ It is also possible to connect appium server that run inside docker-android with - APPIUM_PORT=\ - SELENIUM_HOST="\" - SELENIUM_PORT=\ +- SELENIUM_TIMEOUT=\ To run tests for mobile browser, following parameter can be passed: diff --git a/src/app.py b/src/app.py index c352019..a517ea2 100644 --- a/src/app.py +++ b/src/app.py @@ -148,8 +148,10 @@ def appium_run(avd_name: str): appium_port = int(os.getenv('APPIUM_PORT', 4723)) selenium_host = os.getenv('SELENIUM_HOST', '172.17.0.1') selenium_port = int(os.getenv('SELENIUM_PORT', 4444)) + selenium_timeout = int(os.getenv('SELENIUM_TIMEOUT', 30)) browser_name = default_web_browser if mobile_web_test else 'android' - create_node_config(avd_name, browser_name, appium_host, appium_port, selenium_host, selenium_port) + create_node_config(avd_name, browser_name, appium_host, appium_port, selenium_host, selenium_port, + selenium_timeout) cmd += ' --nodeconfig {file}'.format(file=CONFIG_FILE) except ValueError as v_err: logger.error(v_err) @@ -158,7 +160,7 @@ def appium_run(avd_name: str): def create_node_config(avd_name: str, browser_name: str, appium_host: str, appium_port: int, selenium_host: str, - selenium_port: int): + selenium_port: int, selenium_timeout: int): """ Create custom node config file in json format to be able to connect with selenium server. @@ -167,6 +169,7 @@ def create_node_config(avd_name: str, browser_name: str, appium_host: str, appiu :param appium_port: Port number where where appium server is running :param selenium_host: Host where selenium server is running :param selenium_port: Port number where selenium server is running + :param selenium_timeout: Selenium session timeout in seconds """ config = { 'capabilities': [ @@ -181,7 +184,7 @@ def create_node_config(avd_name: str, browser_name: str, appium_host: str, appiu ], 'configuration': { 'cleanUpCycle': 2000, - 'timeout': 30, + 'timeout': selenium_timeout, 'proxy': 'org.openqa.grid.selenium.proxy.DefaultRemoteProxy', 'url': 'http://{host}:{port}/wd/hub'.format(host=appium_host, port=appium_port), 'host': appium_host, diff --git a/src/tests/unit/test_appium.py b/src/tests/unit/test_appium.py index 87a8533..ed7ed1d 100644 --- a/src/tests/unit/test_appium.py +++ b/src/tests/unit/test_appium.py @@ -58,7 +58,7 @@ class TestAppium(TestCase): def test_config_creation(self): from src import CONFIG_FILE self.assertFalse(os.path.exists(CONFIG_FILE)) - app.create_node_config('test', 'android', '127.0.0.1', 4723, '127.0.0.1', 4444) + app.create_node_config('test', 'android', '127.0.0.1', 4723, '127.0.0.1', 4444, 30) self.assertTrue(os.path.exists(CONFIG_FILE)) os.remove(CONFIG_FILE)