appium脚本(一)

# -*- coding: utf-8 -*-web

#coding=utf-8app

"""dom

    Simple iOS tests, showing accessing elements and getting/setting text from them.iphone

"""测试

import unittestui

import osspa

from random import randintcode

from selenium import webdriverorm

from time import sleepip

class SimpleIOSTests(unittest.TestCase):

    #初始化

    def setUp(self):

        # set up appium

        # app的路径

        app1 = os.path.join(os.path.dirname(__file__),

                           '/Users/123/appium/sample-code/apps/Friday-bmqxtpzhditrczcvfqbkpleoivbm/Build/Products/Release-iphonesimulator',

                           'XXX.app')

        app = os.path.abspath(app1)

        self.driver = webdriver.Remote(

        command_executor='http://127.0.0.1:4723/wd/hub',

        desired_capabilities={

        'app': app,

        'platformName': 'iOS',

        'platformVersion': '7.1',

        'deviceName': 'iPhone Simulator'

         })

    

    def tearDown(self):

        self.driver.quit()

   #开始测试

    def test_find_element(self):

        self.driver.find_element_by_name("开始体验").click()

        self.driver.find_element_by_name("下次").click()

        sleep(5)

        self.driver.find_element_by_name("点此登陆").click()

        self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIATextField[1]").send_keys("test@xt.com")

        self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIASecureTextField[1]").send_keys("123456")

        self.driver.find_element_by_name("登陆").click()

        sleep(5)

        self.driver.find_element_by_name("发现").click()

        sleep(5)

        self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAButton[2]").click()

        sleep(5)

        self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAButton[1]").click()

        sleep(5)

        self.driver.find_element_by_name("立刻体验").click()

        self.driver.find_element_by_name("聊一聊").click()

        sleep(5)

        self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIATextView[1]").send_keys("测试测试测试2")

        sleep(5)

        self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAButton[3]").click()

if __name__ == '__main__':

    suite = unittest.TestLoader().loadTestsFromTestCase(SimpleIOSTests)

    unittest.TextTestRunner(verbosity=2).run(suite)

相关文章
相关标签/搜索