The tutorial is installed by dmg
Links to install appium and python packages on mac http://pan.baidu.com/s/1skUpF6t Password: gyia
In connection to download the relevant installation packages, dmg installation report operation is relatively visible.
Install appium, python, and Sublime text in turn.
The python installation was successful, and the pip tool was installed to install the relevant python library files. The following orders were executed:
Then install appium-python-client and enter commands in the terminal window:sudo easy_install pip
Of course, you can also install selenium. The difference is that appium-python-client has more methods than selenium.sudo pip install Appium-Python-Client
How to verify that the appium and selenium modules are installed successfully, execute the following commands:sudo pip install selenium
Enter the python window to execute the command:python
If the installation is successful, there is no error message:import appium import selenium
Secondly, decompress the WebDriver Agent, enter the WebDriver Agent-master directory, and execute the command:
Installation is complete. If there is a problem, you can refer to the link: https://testerhome.com/topics/4904 With regard to detectors, there is a web version of the detectors in my installation package, which is less complicated to install. Related links: https://github.com/mykola-mokhnach/Appium-iOS-Inspectorsh ./Scripts/bootstrap.sh
Start the WebDriverAgent command as follows:
Start WebDriver Agent for reference: https://github.com/facebook/WebDriverAgent/wiki/Starting-WebDriverAgentxcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=uuid Real machine' test
If all the above environments are configured with ok, then you can start a simple operation example. The XCUITest.rar file under the download path I provided is a test example of XUITest I downloaded from the Internet:
Tester: iphone 6s
ios version: 10.1.1
Take ios_simple.py in XCUITestexamplespython as an example:
""" Simple iOS tests, showing accessing elements and getting/setting text from them. """ import unittest import os from random import randint from appium import webdriver from time import sleep class SimpleIOSTests(unittest.TestCase): def setUp(self): # set up appium app = os.path.abspath('../../apps/TestApp/build/release-iphonesimulator/TestApp.app') self.driver = webdriver.Remote( command_executor='http://127.0.0.1:4723/wd/hub', desired_capabilities={ 'app': app, 'platformName': 'iOS', 'platformVersion': '10.1.1',#Modify to the current version number 'deviceName': 'iPhone 6s',#Modified to the current model 'uuid': '42b9d3af431ac1d5af95018f84cdf525e97089f7' #uuid }) def tearDown(self): self.driver.quit() def _populate(self): # populate text fields with two random numbers els = [self.driver.find_element_by_accessibility_id('TextField1'), self.driver.find_element_by_accessibility_id('TextField2')] self._sum = 0 for i in range(2): rnd = randint(0, 10) els[i].send_keys(rnd) self._sum += rnd def test_ui_computation(self): # populate text fields with values self._populate() # trigger computation by using the button self.driver.find_element_by_accessibility_id('ComputeSumButton').click() # is sum equal ? # sauce does not handle class name, so get fourth element sum = self.driver.find_element_by_accessibility_id('Answer').text self.assertEqual(int(sum), self._sum) def test_scroll(self): els = self.driver.find_elements_by_class_name('XCUIElementTypeButton') els[5].click() sleep(1) try: el = self.driver.find_element_by_accessibility_id('Allow') el.click() sleep(1) except: pass el = self.driver.find_element_by_xpath('//XCUIElementTypeMap[1]') location = el.location self.driver.swipe(start_x=location['x'], start_y=location['y'], end_x=0.5, end_y=location['y'], duration=800) if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(SimpleIOSTests) unittest.TextTestRunner(verbosity=2).run(suite)
unittes framework for testing can be installed by pip command:
pip install unittest
Test cases are ready!
The first step is to start WebDriver Agent
The second step is to configure the port number in appium. The example above is localhost: 4723. By default, you just need to start, or through the command line.
If the command line has - U, you need to comment out uuid in the script, otherwise you will report an error.appium -a 127.0.0.1 -p 4723 -U '45f082689dbaebb0ffa3620b3ae22ad9faff9a30'
The third step is to enter the Appium-iOS-Inspector-master directory and click on the. HTML file to start the service.
Change the attribute values according to the above test cases to sample XCUITest+appium+python.
Running test cases through Sublime text: command+b
Starting the service to be tested on the mobile phone, you can view the elements of the page and operate by locating the elements. Due to the high version of appium, uiautomator is not used in ios test and xcuitest is used. The advantages of using XCUITest are as follows: simplified operation, better scalability and better portability.
1. You can call the element location method in selenium directly, instead of using the find_element_by_ios_uiautomation method, it is more convenient to use.
2. More transplantable
3. Test cases are more reusable
4. Similar to the automated testing process of the web, the performance is better.