testdroid: the powerful and comprehensive api for mobile app development and testing

Post on 16-Jul-2015

1.360 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 1

20 January 2015

Ville-Veikko HelppiTechnical Product Manager

ville-veikko.helppi@bitbar.com

The Powerful and

Comprehensive API for Mobile

App Development and Testing

W E B I N A R

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 2

Agenda

• The Characteristics of Great API

• The Basics of Communication Mechanisms

• Three Categories for API Usage

– Authentication (security)

– Managing Projects

– Getting Results

• Hands-on Example (cURL)

• Additional resources

• Q&A

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 3

The Characteristics of Great

Application Programming

Interface

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 4

• The way to integrate (different) systems

• The way to expose/transport data easily,

automatically and instantly

• Modular, scalable and versatile API calls

• Great standards

– REST(ful) / JSON / OAuth etc.

• Security

– No manual hassling – all communications

through API

Why API?

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 5

• Easy to learn, easy to use, hard to misuse

• Easy to read, maintain, extend

• Appropriate for every user

– Some people can configure/create access,

some only need to use

• Provides all features than can be done

also manually

• Versatile API backs up test automation

approach and complements Agile process

Characteristics of Great API

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 6

APIs Are Not Only for Services!

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 7

The Manual Flow

Application

Results

Logs, outputs, data

Screenshots

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 8

Access Devices via API

Development environments and tools Real Mobile Devices (hundreds of)

Data; Results, Screenshots & Logs

Automatic, instant upload on devices

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 9

The Basics of

Communication Mechanisms

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 10

For example:

GET /oauth/token?client_id=testdroid-cloud-

api&grant_type=password&username=example@bitbar.co

m&password=P4s$w0rd&parameters=more

The Basics

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 11

GET: fetch an existing resource. The URL contains all the

necessary information the server needs to locate and

return the resource.

POST: create a new resource. POST requests usually carry

a payload that specifies the data for the new resource.

PUT: update an existing resource. The payload may

contain the updated data for the resource.

DELETE: delete an existing resource.

The Basics - Verbs

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 12

Requests and Responses

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 13

2xx: Successful

202 Accepted: the request was accepted but may not include the

resource in the response.

204 No Content: there is no message body in the response.

205 Reset Content: indicates to the client to reset its document view.

206 Partial Content: indicates that the response only contains partial

content.

3xx: Redirection

301 Moved Permanently: the resource is now located at a new URL.

303 See Other: the resource is temporarily located at a new URL. The

Location response header contains the temporary URL.

304 Not Modified: the server has determined that the resource has not

changed and the client should use its cached copy.

The Basics – Error Codes

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 14

4xx: Client Error

400 Bad Request: the request was malformed.

401 Unauthorized: request requires authentication. The client can repeat

the request with the Authorization header.

403 Forbidden: server has denied access to the resource.

405 Method Not Allowed: invalid HTTP verb used in the request line, or

the server does not support that verb.

409 Conflict: the server could not complete the request because the client

is trying to modify a resource that is newer than the client's timestamp.

5xx: Server Error

501 Not Implemented: the server does not yet support the requested

functionality.

503 Service Unavailable: this could happen if an internal system on the

server has failed or the server is overloaded.

The Basics – Error Codes

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 15

Access via Comprehensive API

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 16

• Authentication

• Project Management

– Create, Delete, Configure, Managing Users

• Configuring Access and Assets

– Configs, Upload/Download Files (App & Tests)

– Device Access & Device Group Configuration

• Running Tests

– Upload App + Tests <-> Download Results/Data

– Notifications, Sharing, Pre-processing of Data

Access via Comprehensive API

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 17

Authentication

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 18

Authentication

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 19

Authentication

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 20

SEND Header=Accept: application/json

client_id=testdroid_cloud_api

grant_type=password

username=email@address.com

password=XXXXXXXX

CURL:

curl -X POST -H "Accept: application/json" -d "client_id=testdroid-cloud-

api&grant_type=password&username=email@address.com&

password=XXXXXXXX" https://cloud.testdroid.com/oauth/token

Authentication

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 21

Projects and Managing Those

via API

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 22

Get List of Projects

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 23

Get List of Projects

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 24

Get List of Projects

SEND Header=Accept: application/json

Authorization: Bearer <ACCESS_TOKEN>

CURL:

curl -H “Accept: application/json” -H “Authorization: Bearer <ACCESS-

TOKEN>” https://cloud.testdroid.com/api/v2/me/projects

or

curl –H "Accept: application/json"

"https://cloud.testdroid.com/api/v2/me/projects?access_token=<ACCES

S-TOKEN>"

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 25

Create a Project

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 26

Create a Project

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 27

SEND Header=Accept: application/json

Authorization: Bearer <ACCESS_TOKEN>

name=name of new project

CURL:

curl -X POST -d "name=NewProject" -H "Authorization: Bearer

fac84a04-feb0-42ed-a810-6d859e43c123"

https://cloud.testdroid.com/api/v2/me/projects

or

curl -X POST -d "name=NewProject2”

“https://cloud.testdroid.com/api/v2/me/projects?access_token=<ACCESS-TOKEN>"

Create a Project

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 28

Update a Project

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 29

Update a Project

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 30

CURL:

curl -X POST -d "projectId=75013784&name=NewName&description=

Something&common=false" -H "Authorization: Bearer 5f5c3ad0-1f70-4435-

ae4f-ec2a9d20a985"

https://cloud.testdroid.com/api/v2/me/projects/75013784

or

curl -X POST -d "projectId=75013784&name=NewName&description=

Something&common=false"

"https://cloud.testdroid.com/api/v2/me/projects/75013784?access_token=38f57e00-a2f7-40d0-bdc2-e041b95ff43e"

Update a Project

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 31

Upload an App

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 32

Upload an App

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 33

CURL:

curl -F file=@"filename.apk"

"https://cloud.testdroid.com/api/v2/me/projects/<PROJECTNUMBER>/files/application?access_token=<ACCESS-TOKEN>"

Upload an App

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 34

Start a New Test Run

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 35

Start a New Test Run

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 36

CURL:

curl -X POST -d “projectId=<PROJECTID>&name=<NAME OF NEW

TEST RUN>”

“https://cloud.testdroid.com/api/v2/me/projects/<PROJECTID>/runs?access_token=<ACCESS-TOKEN>"

Upload an App

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 37

Upload w/Python

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 38

Get Results from Testdroid

Cloud via API

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 39

Get Details of Test Run

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 40

Get Details of Test Run

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 41

CURL:

curl -H "Accept: application/json"

https://cloud.testdroid.com/api/v2/me/projects/<PROJECTID>/runs/<TESTRUNID>/device-runs?access_token=<ACCESS-TOKEN>

Get Details of Test Run

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 42

Get Device Run Logs

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 43

Get Device Run Logs

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 44

CURL:

curl -H "Accept: application/json"

https://cloud.testdroid.com/api/v2/me/projects/<PROJECTID>/runs/<TE

STRUNID>/device-runs/<DEVICEID>/logs?access_token=<ACCESS-TOKEN> > log.txt

Get Device Run Logs

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 45

Get Device Run Performance

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 46

Get Device Run Performance

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 47

CURL:

curl -H "Accept: application/json"

https://cloud.testdroid.com/api/v2/me/projects/<PROJECTID>/runs/<TE

STRUNID>/device-

runs/<DEVICEID>/performance?access_token=<ACCESS-TOKEN> > log.txt

Get Device Run Performance

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 48

Get Screenshots

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 49

Get Screenshots

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 50

CURL:

(List of screenshots)

curl -H "Accept: application/json"

https://cloud.testdroid.com/api/v2/me/projects/<PROJECTID>/runs/<TE

STRUNID>/device-runs/<DEVICEID>/screenshots?access_token=<ACCESS-TOKEN>

(Specific Screenshot)

curl -H "Accept: application/json"

https://cloud.testdroid.com/api/v2/me/projects/<PROJECTID>/runs/<TE

STRUNID>/device-

runs/<DEVICEID>/screenshots/<SCREENSHOTID>?access_token=<ACCESS-TOKEN>

Get Screenshots

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 51

Hands-on - Let's cURL!

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 52

• Testdroid API for Python– https://github.com/bitbar/testdroid-api-client-python

• Testdroid API for Ruby– https://github.com/bitbar/testdroid-api-client-ruby

• Testdroid API for Java– https://github.com/bitbar/testdroid-

api/tree/master/src/main/java/com/testdroid/api/sample

• Testdroid API description– http://docs.testdroid.com/_pages/client.html

Additional Examples

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 53

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 54

Video recording & slides of this webinar will

be soon available at Vimeo and Slideshare!

Please visit at www.testdroid.com for more

information.

THANK YOU!

W E B I N A R

© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 55

We operate the largest global device

cloud with over 400 devices

instantly available for developers

Devices from the US, Europe, China, Japan and Korea

– global devices for global customers

top related