From 47e968927abd9fcb26086d0f87dff81c462866c1 Mon Sep 17 00:00:00 2001 From: butomo1989 Date: Fri, 2 Jun 2017 14:49:55 +0200 Subject: [PATCH] Updated Sample and End2End Tests --- example/android/python/msite_simple_chrome.py | 21 +++++++++++++++---- .../python/msite_simple_default_browser.py | 11 ++++++++-- src/app.py | 3 ++- src/tests/e2e/test_android_apk.py | 2 +- src/tests/e2e/test_chrome.py | 11 ++++++++++ 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/example/android/python/msite_simple_chrome.py b/example/android/python/msite_simple_chrome.py index 17ea123..3ec6508 100644 --- a/example/android/python/msite_simple_chrome.py +++ b/example/android/python/msite_simple_chrome.py @@ -1,5 +1,7 @@ import unittest +from time import sleep + from appium import webdriver @@ -13,13 +15,24 @@ class MSiteChromeAndroidUITests(unittest.TestCase): 'deviceName': 'Android Emulator', 'appPackage': 'com.android.chrome', 'appActivity': 'com.google.android.apps.chrome.Main', - 'browserName': 'chrome', - 'ignore-certificate-errors': True + 'browserName': 'chrome' } - self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps) + self.driver = webdriver.Remote('http://10.161.128.186:4444/wd/hub', desired_caps) def test_open_url(self): - self.driver.get('http://targeturl.com') + self.driver.get('http://google.com') + + # Handle Welcome Home + self.driver.switch_to.context('NATIVE_APP') + self.driver.find_element_by_id('terms_accept').click() + self.driver.find_element_by_id('negative_button').click() + + # Search for Github + self.driver.switch_to.context('CHROMIUM') + search = self.driver.find_element_by_name('q') + search.send_keys('butomo1989 docker-android') + search.submit() + sleep(2) def tearDown(self): self.driver.quit() diff --git a/example/android/python/msite_simple_default_browser.py b/example/android/python/msite_simple_default_browser.py index 8f1bde2..e6c8343 100644 --- a/example/android/python/msite_simple_default_browser.py +++ b/example/android/python/msite_simple_default_browser.py @@ -1,5 +1,7 @@ import unittest +from time import sleep + from appium import webdriver @@ -15,10 +17,15 @@ class MSiteDefaultBrowserAndroidUITests(unittest.TestCase): 'appActivity': 'com.android.browser.BrowserActivity', 'browserName': 'browser' } - self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps) + self.driver = webdriver.Remote('http://10.161.128.186:4444/wd/hub', desired_caps) def test_open_url(self): - self.driver.get('http://targeturl.com') + self.driver.get('http://google.com') + + search = self.driver.find_element_by_name('q') + search.send_keys('butomo1989 docker-android') + search.submit() + sleep(2) def tearDown(self): self.driver.quit() diff --git a/src/app.py b/src/app.py index 320c926..913677c 100644 --- a/src/app.py +++ b/src/app.py @@ -121,7 +121,8 @@ def appium_run(avd_name: str): subprocess.check_call('xterm -T "{title}" -n "{title}" -e \"{cmd}\"'.format(title=title, cmd=cmd), shell=True) -def create_node_config(avd_name: str, browser_name: str, appium_host: str, appium_port: int, selenium_host: str, selenium_port: int): +def create_node_config(avd_name: str, browser_name: str, appium_host: str, appium_port: int, selenium_host: str, + selenium_port: int): """ Create custom node config file in json format to be able to connect with selenium server. diff --git a/src/tests/e2e/test_android_apk.py b/src/tests/e2e/test_android_apk.py index 64c393d..89cf2fe 100644 --- a/src/tests/e2e/test_android_apk.py +++ b/src/tests/e2e/test_android_apk.py @@ -4,7 +4,7 @@ from unittest import TestCase from appium import webdriver -class TestE2EApp(TestCase): +class TestE2EAndroidApk(TestCase): def setUp(self): desired_caps = { diff --git a/src/tests/e2e/test_chrome.py b/src/tests/e2e/test_chrome.py index 746e334..94dfcf3 100644 --- a/src/tests/e2e/test_chrome.py +++ b/src/tests/e2e/test_chrome.py @@ -18,5 +18,16 @@ class TestE2EChrome(TestCase): def test_open_url(self): self.driver.get('http://google.com') + # Handle Welcome Home + self.driver.switch_to.context('NATIVE_APP') + self.driver.find_element_by_id('terms_accept').click() + self.driver.find_element_by_id('negative_button').click() + + # Search for Github + self.driver.switch_to.context('CHROMIUM') + search = self.driver.find_element_by_name('q') + search.send_keys('butomo1989 docker-android') + search.submit() + def tearDown(self): self.driver.quit()