Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- centos
- ubuntu
- rethinkdb
- nGrinder
- postgres
- mysql
- appium server
- openpyxl
- 28015
- create table
- ftp
- kitura
- SWIFT
- PYTHON
- nohup
- GoCD
- ssh
- STF_PortForwarding
- Jupyter
- appium
- port forwarding
- STF
- insert
- Materials
- Jupyter Notebook
- nmap
- 실행권한
- perfect
- postgresql
- sshpass
Archives
- Today
- Total
don't stop believing
Appium client 설치 및 실행 Native App (Python) 본문
Appium 설치와 구성, Instpector 확인까지 했다면 Python Appium Client로 연결하고 동작시켜 봅시다.
설치는 pip으로 해줍니다.
$ pip3 install Appium-Python-Client
먼저 Android부터 해봅시다.
Python 코드는 아래와 같습니다.
''' Android Native Script ''' import unittest import os from appium import webdriver from time import sleep from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC class TableSearchTest(unittest.TestCase): def setUp(self): # Set up appium app = os.path.join(os.path.dirname(__file__), '/Users/tongchunkim/Documents/TestAppium/appfiles/', 'KakaoGameSDK_Test_App_3.5.1.148.apk') app = os.path.abspath(app) self.driver = webdriver.Remote( command_executor='http://127.0.0.1:4723/wd/hub', desired_capabilities={ 'app': app, 'platformName': 'Android', 'platformVersion': '6.0', 'deviceName': 'V10', 'automationName': 'Appium', 'appPackage': 'com.kakaogame.sample', 'appActivity': 'com.kakaogame.sample.SampleActivity' }) def test_search_field(self): driver = self.driver wait = WebDriverWait(driver, 20) el1 = wait.until(EC.element_to_be_clickable((By.ID, 'com.kakaogame.sample:id/login_ui_button'))) el1.click() el2 = driver.find_element_by_id("com.kakaogame.sample:id/kakao_game_login_idp_item") el2.click() sleep(5) # you could see the failure. idpCode = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout[2]/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.support.v4.view.ViewPager/android.widget.ListView/android.widget.FrameLayout[4]/android.widget.TextView") self.assertEqual('iPad', idpCode.get_attribute('text')) sleep(5) el3 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout[2]/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.support.v4.view.ViewPager/android.widget.ListView/android.widget.FrameLayout[6]/android.widget.Button") el3.click() sleep(5) el4 = driver.find_element_by_id("com.kakaogame.sample:id/kakao_game_sdk_logout_btn_ok") el4.click() sleep(10) def tearDown(self): self.driver.quit() if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(TableSearchTest) unittest.TextTestRunner(verbosity=2).run(suite)
다음은 iOS 입니다.
''' iOS Native Script ''' import unittest import os from appium import webdriver from time import sleep from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC class TableSearchTest(unittest.TestCase): def setUp(self): # Set up appium app = os.path.join(os.path.dirname(__file__), '/Users/tongchunkim/Documents/TestAppium/appfiles/', 'com.kakaogames.sdk.sample.ipa') app = os.path.abspath(app) self.driver = webdriver.Remote( command_executor='http://127.0.0.1:4723/wd/hub', desired_capabilities={ 'platformName': 'ios', 'platformVersion': '11.0', 'deviceName': 'iPhone 6', 'automationName': 'XCUITest', 'newCommandTimeout': 7200, 'bundleId': 'com.kakaogames.sdk.sample', 'udid': '73439839ee3db7b59fcdd8bc3aa8cc4862006b7b', 'xcodeOrgId': 'WVC7779982', 'xcodeSigningId': 'iPhone Developer' }) def test_search_field(self): driver = self.driver wait = WebDriverWait(driver, 20) startButton = wait.until(EC.element_to_be_clickable((By.XPATH, '//XCUIElementTypeButton[@name="Start"]'))) startButton.click() loginButton = wait.until(EC.element_to_be_clickable((By.XPATH, '//XCUIElementTypeButton[@name="Login"]'))) loginButton.click() guestLoginButton = wait.until(EC.element_to_be_clickable((By.XPATH, '//XCUIElementTypeButton[@name=" 게스트 로그인"]'))) guestLoginButton.click() guestLoginConfirm = wait.until(EC.element_to_be_clickable((By.XPATH, '//XCUIElementTypeButton[@name="확인"]'))) guestLoginConfirm.click() logoutButton = wait.until(EC.element_to_be_clickable((By.XPATH, '//XCUIElementTypeButton[@name="logout"]'))) logoutButton.click() logoutConfirm = wait.until(EC.element_to_be_clickable((By.XPATH, '//XCUIElementTypeButton[@name="로그아웃"]'))) logoutConfirm.click() def tearDown(self): self.driver.quit() if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(TableSearchTest) unittest.TextTestRunner(verbosity=2).run(suite)
'Testing Automation > Appium' 카테고리의 다른 글
iOS 실행관련 몇 가지 사항 (0) | 2017.11.28 |
---|---|
Enterprise App 테스트 (소스없는 api 파일 실행) (0) | 2017.11.27 |
Appium Server 실행 (Command line) (0) | 2017.11.01 |
Appium Android Inspector 실행 (0) | 2017.10.30 |
Appium iOS inspector 실행 (2) | 2017.10.25 |
Comments