# -*- 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)