2017-03-05 4 views
0

나는 appium 서버를 시작하고 avd 관리자에서 수동으로 에뮬레이터를 시작합니다. 이 두 단계를 appium python 클라이언트를 사용하여 자동화하고 싶습니다. 는 동일한에 대한 몇 가지 포인터를 제공시겠습니까 :appium python 클라이언트에서 에뮬레이터 시작

class ChessAndroidTests(unittest.TestCase): 
    "Class to run tests against the Chess Free app" 
    def setUp(self): 
     "Setup for the test" 
     desired_caps = {} 
     desired_caps['platformName'] = 'Android' 
     desired_caps['platformVersion'] = '4.2' 
     desired_caps['deviceName'] = 'Android Emulator' 
     # Returns abs path relative to this file and not cwd 
     desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'D:\Programs\myapp\Chess Free.apk')) 
     desired_caps['appPackage'] = 'uk.co.aifactory.chessfree' 
     desired_caps['appActivity'] = '.ChessFreeActivity' 
     self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) 

    def tearDown(self): 
     "Tear down the test" 
     self.driver.quit() 

    def test_single_player_mode(self): 
     "Test the Single Player mode launches correctly" 
     element = self.driver.find_element_by_name("PLAY!") 
     element.click() 
     self.driver.find_element_by_name("Single Player").click() 
     textfields = self.driver.find_elements_by_class_name("android.widget.TextView") 
     self.assertEqual('MATCH SETTINGS', textfields[0].text) 

#---START OF SCRIPT 
if __name__ == '__main__': 
    suite = unittest.TestLoader().loadTestsFromTestCase(ChessAndroidTests) 
    unittest.TextTestRunner(verbosity=2).run(suite) 

답변

0

내가 똑같은 일을하고 싶었다. 나는 이런 식으로했다 : 에뮬레이터를 실행하고 스크립트를 시작 사이에 지연이있을 것이라는 점을

def runAll(self,*args): 
    subprocess.Popen(['/Users/User/Library/Android/sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5X_API_22'],shell=True) 
    subprocess.Popen(['appium --avd Nexus_5X_API_22'],shell=True) 
    subprocess.Popen(['mocha /Users/User/Documents/dev/engineerappcopy/tests/testLoginPage.js --platform android'],shell=True) 

주, 별도로이 작업을 수행하는 것이 현명 할 수있다. 원하는 경우 Appium 기능을 명령에 추가하여 Appium 기능을 정의 할 수도 있습니다.

'appium'뒤에 appium 경로를 정의해야 할 수도 있습니다. 때로는 Popen에 전체 경로가 필요하거나 172 오류가 발생하는 경우가 있습니다. 도움이 되었기를 바랍니다.

https://docs.python.org/2/library/subprocess.html