GithubHelp home page GithubHelp logo

jacky-young / atip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from honry/atip

0.0 2.0 0.0 10.23 MB

Temporary repo for enable UIautomator as a backend in ATIP

Python 92.20% Gherkin 4.27% Shell 3.53%

atip's Introduction

ATIP - a new BDD binding library

Introduction

ATIP(Application Test in Python), a "behave" binding library as the bridge between application and BDD to "behave", and use WebDriver and platform interfaces to implement detailed BDD steps for application.

Configuration

Environmental controls. In ATIP usage, you can write the environment initial processes in config file - environment.py. ATIP provides a template of "environment.py" for tests developers. This template supports running tests independently by "behave" tool.

In Crosswalk testing, the template need to know the some test vars, e.g. which device be tested? which test platform? Some WebDriver vars. the vars can be got by following ways:

  • By environment vars:
    TEST_PLATFORM: android, tizen, chrome_ubuntu, others(if have)
    DEVICE_ID
    CONNECT_TYPE: adb, sdb
    WEBDRIVER_VARS: webdriver_url, desired_capabilities, others
    LAUNCHER: XWalkLauncher, CordovaLauncher

ATIP source provides a script "tools/set_env.sh" which can help you to setup those environment vars. Especially, the environment.py template can get those environment vars from Testkit-lite tool automatically:

A JSON config file which named "bdd.json for environment vars sharing, a template provided for reference: "atip/tools/bdd.*.json"

  • Configuration source layout
tools/
|-- set_env.sh
|-- bdd.chrome.json
|-- bdd.android_cordova.json
|-- bdd.android_xwalk.json
`-- bdd.xw_tizen.json

Tests Development

Before below sections, you'd better already pretty familiar with the tests developing with "behave": "behave" docs. A typical "behave" based tests source layout as below:

tests/
|-- environment.py
|-- steps
|   `-- steps.py
`-- test.feature
 
  • test.feature

A simple feature example as below

Feature: api tests
    Scenario: api test 001
        When launch "haha"
         And I go to "http://www.google.com"
         And I wait for 1 seconds
  • steps.py

A simple step example as below

@step(u'I go to "{url}"')
def i_visit_url(context, url):
    url = get_page_url(context, url)
    assert context.web.switch_url(url, True)

ATIP Library

  • WebDriver Library Overview
Category Steps
Web Element Management Create element
Click element
Find element(s) by id
Find element(s) by name
Find element(s) by tag name
Find element(s) by xpath
Find element(s) by class name
Find element(s) by css selector
Find element(s) by link text
Find element(s) by partial link text
Window Management get current window handle
get window position
get window size
maximize window
set window position
set window size
close current window
switch to alert
switch to window
switch to frame
Page Management get url of current page
get source of current page
get page title
refresh current page
forward the page
backward the page
Cookie add cookie
get cookie(s)
delete cookie
delete all cookies
Execution External execute command
execute script synchronously
execute script asynchronously
Image Processing get screenshot as base64
get screenshot as file/png
  • Uiautomator Library Overview
Category Steps
Android System Operation Turn on/off device
Press hard/soft key
Set device orientation
Freeze/unfreeze device rotation
Take screenshot
Open notification
Open quick settings
Identify current launched app
Gesture Action Fling by orientation and direction
Fling to end
Scroll forward vertically
Scroll to end
Scroll to text
Swipe object to some direction
Watcher Management Register watcher
Remove all watchers
Reset all watchers
Run all watchers
Selector Management Select object by key, value and class name
Select any object by value and class name
Select TextView object by name
Select Button object by name
Select Edit object by name
Select ImageView object by name
Select ImageButton object by name
Select View object by desc
Select Web object by desc
Select object by direction and class name
Wait for object show
Wait for object gone
Object Management Click object
Edit text
Get object info from temp by key
Get object info by text
Save object info to temp
  • Functions Category
    "web": web based(Webdriver API) functions
    "native": native based functions (TBD)
    "common": common operations cross different platforms, e.g. call python image lib to compare image files
    "android": Android platform specific functions which is implemented by uiautomator
    "tizen": Tizen platform specific functions

  • "web" steps - done

@step(u'launch "{app_name}"')
@step(u'I launch "{app_name}" with "{apk_pkg_name}" and "{apk_activity_name}"')
@step(u'switch to "{app_name}"')
@step(u'I go to "{url}"')
@step(u'I reload')
@step(u'I go back')
@step(u'I go forward')
@step(u'The current URL should be "{text}"')
@step(u'I should see title "{text}"')
@step(u'I should see "{text}"')
@step(u'I should not see "{text}"')
@step(u'I should see "{text}" in {timeout:d} seconds')
@step(u'I should not see "{text}" in {timeout:d} seconds')
@step(u'I should see "{text}" in "{key}" area')
@step(u'I press "{key}"')
@step(u'press "{key_c}" in "{key_p}"')
@step(u'I click "{key}"')
@step(u'click "{key_c}" in "{key_p}"')
@step(u'I click coords {x:d} and {y:d} of "{key}"')
@step(u'I fill in "{key}" with "{text}"')
@step(u'I check "{key}"')
@step(u'I uncheck "{key}"')
@step(u'I should see an alert')
@step(u'I should not see an alert')
@step(u'I accept the alert')
@step(u'I should see an alert with text "{text}"')
  • "android" steps - done
@step(u'I launch "{app_name}" with "{apk_pkg_name}" and "{apk_activity_name}" on android')
@step(u'I turn on device')
@step(u'I turn off device')
@step(u'I set orientation "{orientation}"')
@step(u'I take screenshot as "{name}"')
@step(u'I open notification')
@step(u'I open quick settings')
@step(u'I press "{key}" key')
@step(u'I scroll to end')
@step(u'I fling "{orientation}" goto "{direction}"')
@step(u'I swipe object "{key}" to "{orientation}"')
@step(u'I force to run all watchers')
@step(u'I remove all watchers')
@step(u'I register watcher "{watcher_name}" when "{when_text}" click "{click_text}"')
@step(u'I register watcher2 "{watcher_name}" when "{when_text1}" and "{when_text2}" click "{click_text}"')
@step(u'I should see text "{text_name}"')
@step(u'I should see image "{image_name}"')
@step(u'I should see web "{web_desc}"')
@step(u'I should see view "{view_desc}"')
@step(u'I should see "{class_name}" on the "{relative}" side of text "{text_name}"')
@step(u'I should see "{class_name}" on the "{relative}" side of view "{view_desc}"')
@step(u'I should see "{class_target}" on the "{relative}" side of any "{class_name}" "{value_name}"')
@step(u'I wait object "{key}" exist for "{time_out}"')
@step(u'I wait object "{key}" gone for "{time_out}"')
@step(u'I click button "{button_name}"')
@step(u'I click other "{class_name}" by "{which_key}" "{which_value}"')
@step(u'I click object "{key}"')
@step(u'I edit text "{edit_text}" to input "{text}"')
@step(u'I edit index {n:d} text to input "{text}"')
@step(u'I compare text "{text_name}" info "{what}" with "{except_result}"')
@step(u'I compare view "{view_desc}" info "{what}" with "{except_result}"')
@step(u'I compare object "{key1}" equal "{key2}" on info "{what}"')
@step(u'I compare object "{key1}" unequal "{key2}" on info "{what}"')
@step(u'I save text object "{text_name}" to temporary value "{key}"')
@step(u'I save view object "{view_desc}" to temporary value "{key}"')
@step(u'I save any object "{class_name}" "{value_name}" to temporary value "{key}"')
@step(u'I save "{class_name}" on the "{relative}" side of text "{text_name}" to temporary value "{key}"')
@step(u'I save "{class_name}" on the "{relative}" side of view "{view_desc}" to temporary value "{key}"')
@step(u'I save "{class_target}" on the "{relative}" side of any "{class_name}" "{value_name}" to temporary value "{key}"')
@step(u'I process text object "{text_name}"')
@step(u'I process view object "{view_desc}"')
@step(u'I process any object "{class_name}" "{value_name}"')
@step(u'I process "{class_name}" on the "{relative}" side of text "{text_name}"')
@step(u'I process "{class_name}" on the "{relative}" side of view "{view_desc}"')
@step(u'I process "{class_target}" on the "{relative}" side of any "{class_name}" "{value_name}"')
@step(u'I reload process result to temporary value "{key}"')
  • "common" steps - done
@step(u'I wait for {timeout:d} seconds')
@step(u'call "{js}" scripts') - TBD
@step(u'call PIL to handle "{image_file}"') - TBD

Run Tests

  • Testkit-lite: Please check testkit-lite project for details
  • Behave: setup test ENVs by set_env.sh or bdd.json firstly, then run "behave" as:
    cd path-to/tests
    behave

atip's People

Contributors

honry avatar jacky-young avatar

Watchers

 avatar  avatar

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.