appium 测试iOS app demo(python语言)

0. iOS自动测试环境搭建

参考iOS自动测试环境搭建(Appium)

1. 打开appium-desktop

2. 打开WebDriverAgent 测试

方法1:

在xcode中打开WebDriverAgent项目,cmd+u进入测试

方法2:

在shell中输入指令xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=' test
udid换成自己设备的id(可用命令idevice_id -l查看)

3. 运行脚本:

下面代码供参考:

import unittest
import os
from appium import webdriver
import time

class appiumSimpleTest(unittest.TestCase):
    def setUp(self):
        app = os.path.abspath('')
        self.driver = webdriver.Remote(
            command_executor='http://0.0.0.0:4723/wd/hub',
            desired_capabilities={
                'app': app,
                'platformName': 'iOS',
                'platformVersion': '',
                'deviceName': '',#like '9.3.2'
                'bundleId': '', #like com.xxx.xxxxx
                'udid': '',#like com.xxxxxxxxxxxxxxxxxxxxxxxxxxx  (40 letters)
                'automationName': 'XCUITest',
                "xcodeOrgId": "",#like xxxxxxxxxx (10 letters)
                "xcodeSigningId": "iPhone Developer"
            }
        )

    def test_push_view(self):
        next_view_button = self.driver.find_element_by_accessibility_id("test") #find a button named 'test'
        next_view_button.click()
        time.sleep(2)


    def tearDown(self):
        return super().tearDown()


if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(appiumSimpleTest)
    unittest.TextTestRunner(verbosity=2).run(suite)

其中部分内容替换成自己的即可

你可能感兴趣的:(appium 测试iOS app demo(python语言))