Possibility to run appium with custom chromedriver executable (#12)

* Possibility to run appium with custom chromedriver executable
* Unit test added
* README update
This commit is contained in:
Andrejs
2017-06-09 10:44:58 +02:00
committed by Budi Utomo
parent b7c4538896
commit 6406504f94
3 changed files with 22 additions and 0 deletions
+4
View File
@@ -102,6 +102,10 @@ def appium_run(avd_name: str):
cmd = 'appium'
local_ip = os.popen('ifconfig eth0 | grep \'inet addr:\' | cut -d: -f2 | awk \'{ print $1}\'').read().strip()
chromedriver_executable = os.getenv('CHROMEDRIVER_EXECUTABLE', False)
if chromedriver_executable:
cmd += ' --chromedriver-executable {executable}'.format(executable=chromedriver_executable)
grid_connect = convert_str_to_bool(str(os.getenv('CONNECT_TO_GRID', False)))
logger.info('Connect to selenium grid? {connect}'.format(connect=grid_connect))
if grid_connect:
+12
View File
@@ -12,8 +12,20 @@ class TestAppium(TestCase):
def setUp(self):
os.environ['CONNECT_TO_GRID'] = str(True)
os.environ['CHROMEDRIVER_EXECUTABLE'] = str(False)
self.avd_name = 'test_avd'
@mock.patch('os.popen')
@mock.patch('subprocess.check_call')
def test_with_chromedriver_executable(self, mocked_os, mocked_subprocess):
os.environ['CONNECT_TO_GRID'] = str(False)
os.environ['CHROMEDRIVER_EXECUTABLE'] = '/root/chromedriver'
self.assertFalse(mocked_os.called)
self.assertFalse(mocked_subprocess.called)
app.appium_run(self.avd_name)
self.assertTrue(mocked_os.called)
self.assertTrue(mocked_subprocess.called)
@mock.patch('os.popen')
@mock.patch('subprocess.check_call')
def test_without_selenium_grid(self, mocked_os, mocked_subprocess):