Coder Social home page Coder Social logo

pyfrank's Introduction

pyfrank - python binding for iOS automation using frank.

pyfrank is an API to interact with frank, the iOS automation framework.

#Installation

Option 1:

  1. Clone this repo or download the sources

  2. cd pyfrank

  3. python setup.py build

  4. sudo python setup.py install

Option 2:

sudo pip install pyfrank

#It's that simple

from pyfrank import *

# We are running a simulator with frank locally on port 32765
device = Device(host='127.0.0.1', port=32765)

# Get the view representing a tab-bar button with the label "Mail"
view = device.getView(UiQuery("tabBarButton", {'marked': "Mail" }))

# Touch the button
response = view.touch()

if isinstance(response, Success):
    logging.info("Test mail button succeeded!");
elif isinstance(response, Failure):
    logging.error("Test mail button failed: %s", response)

#The object model

Device

The first entry point for interacting with frank. It's constructor receives the host and the port of the frank enabled device.

###Example:

from pyfrank import *

device = Device("127.0.0.1", 32765)
    
# Type text into the keyboard
device.typeIntoKeyboard("abc")

# Execute an application on the device
device.appExec("appName", "arg1", "arg2", ...)

# Get the accesibility state
accessibilityEnabled = device.accessibilityCheck()

# Get the device orientation
orientation = device.getOrientation()
if orientation == Orientation.PORTRAIT:
    print "Portrait"
elif orientation == Orientation.LANDSCAPE:
    print "Landscape"

# Get the application layout graph
dump = device.dump()

UiQuery

In frank views can be found using a special query language called "UiQuery".

###Example:

from pyfrank import *

UiQuery("view:'UIImageView' marked:'ProfilePicture'")

View

View allows to perform operations on the view(s) that match a UiQuery.

#Get the profile picture view
view = device.getView(UiQuery({'view': 'UIImageView'}, {'marked': 'ProfilePicture'}))

#Flash the profile picture
r = view.flash() 

#Test for success
if isinstance(r, Success):
    print "Flashed the profile picture!"
else:
    print "Failed flashing profile picture"

#Touch the profile picture
r = view.touch()


#Get the title text input view
input = device.getView(UiQuery({'view', 'UITextField'}, {'marked': 'Title'}))
    
r = input.setText("New title text")    

if isinstance(r, Success):
    print "Title input was changed successfully."
else:
    print "Failed changing title input"

Retrieve a view property

view = device.getView(UiQuery({'view':'UILabel'}, { 'marked':'Pull down to refresh...' }))

# Pull out the 'text' attribute. Every attribute exposed by frank can be called as a method on the view to retrieve it's value.
r = view.text()

if isinstance(r, Success):
    labelText = r['results'][0]

    print "The text of the UILabel is", labelText
else:
    print "I seriously failed to retrieve the UILabel text attribute", r

#More information on frank

http://testingwithfrank.com/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.