diff --git a/README.md b/README.md index 7157da9..bee9c17 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,6 @@ docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -p 4723:4723 - ### Connect to Selenium Grid -![][selenium grid] -![][devices are connected with selenium grid] - It is also possible to connect appium server that run inside docker-android with selenium grid by passing following environment variables: - CONNECT\_TO\_GRID=True @@ -113,15 +110,13 @@ It is also possible to connect appium server that run inside docker-android with - SELENIUM_HOST="\" - SELENIUM_PORT=\ -```bash -docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e APPIUM=True -e CONNECT_TO_GRID=True -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 --name android-container butomo1989/docker-android-x86-7.1.1 -``` - To run tests for mobile browser, following parameter can be passed: - MOBILE\_WEB\_TEST=True -Check [README.md](/example/compose/README.md) on how to run complete selenium grid using docker-compose +```bash +docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e APPIUM=True -e CONNECT_TO_GRID=True -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 -e MOBILE_WEB_TEST=True --name android-container butomo1989/docker-android-x86-7.1.1 +``` ### Share Volume @@ -131,6 +126,17 @@ If you want to use appium to test UI of your android application, you need to sh docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -v $PWD/example/sample_apk:/root/tmp -e DEVICE="Nexus 5" -e APPIUM=True -e CONNECT_TO_GRID=True -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 --name android-container butomo1989/docker-android-x86-7.1.1 ``` +### Docker-Compose + +![][compose] +![][connected_devices] + +There is [example of compose file] to run complete selenium grid and docker-android container as nodes. [docker-compose] version [1.13.0] or higher is required to be able to execute that compose file. + +```bash +docker-compose up -d +``` + Control android emulator outside container ------------------------------------------ @@ -193,7 +199,10 @@ docker exec -it android-container tail -f /var/log/supervisor/docker-android.std [robotium]: [docker android samsung]: [docker android nexus]: -[selenium grid]: -[devices are connected with selenium grid]: +[compose]: +[connected_devices]: +[example of compose file]: +[docker-compose]: +[1.13.0]: [adb_connection]: [sms]: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7c8c249 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,60 @@ +# Note: It requires docker-compose 1.13.0 +# +# Usage: docker-compose up -d +version: "2.2" + +services: + # Selenium hub + selenium_hub: + image: selenium/hub:3.4.0 + ports: + - "4444:4444" + + # Docker-Android for Android application testing + nexus_7.1.1: + image: butomo1989/docker-android-x86-7.1.1 + privileged: true + # Change path of apk that you want to test. I use sample_apk that I provide in folder "example" + volumes: + - $PWD/example/sample_apk:/root/tmp + # Increase scale number if needed + scale: 1 + ports: + - 6080 + environment: + - DEVICE=Nexus 5 + - CONNECT_TO_GRID=True + - APPIUM=true + - SELENIUM_HOST=selenium_hub + + # Docker-Android for mobile website testing with chrome browser + # Chrome browser exists only for version 7.0 and 7.1.1 + samsung_galaxy_web_7.1.1: + image: butomo1989/docker-android-x86-7.1.1 + privileged: true + # Increase scale number if needed + scale: 1 + ports: + - 6080 + environment: + - DEVICE=Samsung Galaxy S6 + - CONNECT_TO_GRID=True + - APPIUM=true + - SELENIUM_HOST=selenium_hub + - MOBILE_WEB_TEST=True + + # Docker-Android for mobile website testing with default browser + # Default browser exists only for version 5.0.1, 5.1.1 and 6.0 + samsung_galaxy_web_5.1.1: + image: butomo1989/docker-android-x86-5.1.1 + privileged: true + # Increase scale number if needed + scale: 1 + ports: + - 6080 + environment: + - DEVICE=Samsung Galaxy S6 + - CONNECT_TO_GRID=True + - APPIUM=true + - SELENIUM_HOST=selenium_hub + - MOBILE_WEB_TEST=True diff --git a/example/android/python/app_simple.py b/example/android/python/app_simple.py index 8eaa2c6..e151afe 100644 --- a/example/android/python/app_simple.py +++ b/example/android/python/app_simple.py @@ -11,9 +11,10 @@ class SimpleAndroidUITests(unittest.TestCase): 'deviceName': 'Android Emulator', 'automationName': 'UIAutomator2', 'app': '/root/tmp/sample_apk_debug.apk', - 'avd': 'samsung_galaxy_s6_7.1.1' + 'browserName': 'android', + 'avd': 'nexus_5_7.1.1' } - self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) + self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps) def tearDown(self): self.driver.quit() diff --git a/example/android/python/msite_simple_chrome.py b/example/android/python/msite_simple_chrome.py index 32bb198..17ea123 100644 --- a/example/android/python/msite_simple_chrome.py +++ b/example/android/python/msite_simple_chrome.py @@ -13,9 +13,10 @@ class MSiteChromeAndroidUITests(unittest.TestCase): 'deviceName': 'Android Emulator', 'appPackage': 'com.android.chrome', 'appActivity': 'com.google.android.apps.chrome.Main', - 'avd': 'samsung_galaxy_s6_7.1.1' + 'browserName': 'chrome', + 'ignore-certificate-errors': True } - self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) + self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps) def test_open_url(self): self.driver.get('http://targeturl.com') diff --git a/example/android/python/msite_simple_default_browser.py b/example/android/python/msite_simple_default_browser.py index e6fe319..8f1bde2 100644 --- a/example/android/python/msite_simple_default_browser.py +++ b/example/android/python/msite_simple_default_browser.py @@ -13,9 +13,9 @@ class MSiteDefaultBrowserAndroidUITests(unittest.TestCase): 'deviceName': 'Android Emulator', 'appPackage': 'com.android.browser', 'appActivity': 'com.android.browser.BrowserActivity', - 'avd': 'samsung_galaxy_s6_6.0' + 'browserName': 'browser' } - self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) + self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps) def test_open_url(self): self.driver.get('http://targeturl.com') diff --git a/example/compose/README.md b/example/compose/README.md deleted file mode 100644 index e258264..0000000 --- a/example/compose/README.md +++ /dev/null @@ -1,16 +0,0 @@ -[docker-compose.yml](/example/compose/docker-compose.yml) file for setting up selenium grid. ------------------------------------------------------ - -Example compose file which can be used to set up selenium grid hub with emulator nodes connected to it -![](/images/compose_selenium_grid.png) - -Requirements -============ -docker-compose -for `scale:` option docker-compose v1.13.0 and newer is required - -Quick Start -=========== -```bash -docker-compose up -``` diff --git a/example/compose/docker-compose.yml b/example/compose/docker-compose.yml deleted file mode 100644 index dfdc33e..0000000 --- a/example/compose/docker-compose.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: "2.2" -services: - hub: - image: selenium/hub:3.4.0 - ports: - - "4444:4444" - - node_samsung_7.1.1: - image: butomo1989/docker-android-x86-7.1.1 - privileged: true - scale: 2 - ports: - - 6080 - environment: - - DEVICE=Samsung Galaxy S6 - - CONNECT_TO_GRID=True - - APPIUM=true - - SELENIUM_HOST=hub - - node_nexus_web_7.1.1: - image: butomo1989/docker-android-x86-7.1.1 - privileged: true - scale: 2 - ports: - - 6080 - environment: - - DEVICE=Nexus 5 - - CONNECT_TO_GRID=True - - APPIUM=true - - SELENIUM_HOST=hub - - MOBILE_WEB_TEST=True diff --git a/images/compose.png b/images/compose.png new file mode 100644 index 0000000..7bf2108 Binary files /dev/null and b/images/compose.png differ diff --git a/images/compose_selenium_grid.png b/images/compose_selenium_grid.png deleted file mode 100644 index f078b61..0000000 Binary files a/images/compose_selenium_grid.png and /dev/null differ diff --git a/images/connected_devices.png b/images/connected_devices.png new file mode 100644 index 0000000..fd9e32e Binary files /dev/null and b/images/connected_devices.png differ diff --git a/images/connected_with_grid.png b/images/connected_with_grid.png deleted file mode 100644 index 43401e9..0000000 Binary files a/images/connected_with_grid.png and /dev/null differ diff --git a/images/selenium_grid.png b/images/selenium_grid.png deleted file mode 100644 index 0c9efc6..0000000 Binary files a/images/selenium_grid.png and /dev/null differ