Test iOS projects with Python automation

Source: Internet
Author: User

WebDriverAgentA webdriver server is implemented on the iOS side, and with this server we can remotely control the iOS device. You can start, kill the app, tap, scroll through the view, or make sure the page is displayed correctly.

Project Address: Https://github.com/facebook/WebDriverAgent

facebook-wdaThis Python library communicates directly with webdriveragent by constructing HTTP requests directly.

Project Address: Https://github.com/openatx/facebook-wda

Installing Webdriveragent

Download code from GitHub

1 git clone https://github.com/facebook/WebDriverAgent

Installation dependencies

1 ./scripts/bootstrap.sh

Webdriveragent uses Carthage to manage dependencies, so you need to install the Carthage environment.

Configure the certificate, and then Command+U run it, not Command+R .

If you want to use USB communication, look here Https://github.com/facebook/WebDriverAgent/wiki/USB-support

Effect after normal start

The output of your phone IP address instructions started normally.

Visit Http://ip:8100/inspector to see the app's UI layer for easy writing of test scripts.

Installing Facebook-wda
1 Pip Install--pre Facebook-wda
Small test sledgehammer: Complete the app download automatically, install

(Remove Touch ID to install app first)

Use Safari to jump app on AppStore page

1234567 App_url = ' https://itunes.apple.com/cn/app/id425349261?mt=8 'c = Wda. Client (' http://ip:8100 ')# Open Safaris = c.session (' Com.apple.mobilesafari ', ['-U ', App_url] )e = s (name=u ' open '). Get (timeout=, raise_error=False)E.tap () time.sleep (5 )

Download app

1234567891011121314151617181920212223242526 s = c.session ()if s (classname=' Button ', name=u ' get '). Wait (timeout=, raise_error=False): # has not been downloaded beforePrint' Click to get ')E = S (classname=' Button ', name=u ' get '). Get (timeout=2, raise_error=False) E.tap ()# Wait for display installationE = S (classname=' Button ', name=u ' install '). Get (timeout=, raise_error=False) If E:E.tap () Print (' Do I need to enter a password ')if S (classname="Securetextfield"). Wait (timeout=5, raise_error=False): Print' Enter password ')E = S (classname="Securetextfield"). Get (timeout=5, raise_error=False) E.set_text ("password")Print' click to login ')E = S (classname=' Button ', name=u ' login '). Get (timeout=5, raise_error=False) E.tap ()Else:Print' No need to enter a password ')elif S (classname=' Button ', name=u ' re-download '). Wait (timeout=5, raise_error=False): Print' Click to re-download ')E = S (classname=' Button ', name=u ' re-download '). Get (timeout=, raise_error=False) E.tap ()Else:Exit ()

Show Download Progress

1234567891011121314151617 # There's a loading processwhile S (classname=' Button ', name=u ' is loading '). Wait (timeout=3, raise_error=False): Pass# Check every 3 seconds for download completePrint' Wait for download to complete ')while S (classname=' Button ', name=u ' is downloading '). Wait (timeout=3, raise_error=False): Value = S (classname=' Button ', name=u ' is downloading '). Get (timeout=3, raise_error=False). Value if Value is None: ContinueSys.stdout.write ("downloaded%s\r"% value.encode ("Utf-8")) Sys.stdout.flush () Time.sleep (1)Sys.stdout.write ("Downloaded 100%\r")Sys.stdout.flush ()# Download CompletePrint' \ n Download complete ')

Save the file as test_demo.py, run the test

12345 $ python test_demo.py Click Re-download wait download complete downloaded 100% Download complete
Summary

By using WebDriverAgent and facebook-wda being able to test any app (you can also make simple app aids, such as a recent fire jump).

Test iOS projects with Python automation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.