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

55
© Copyrights by Bitbar Technologies Ltd. 2015 All rights reserved. 1 20 January 2015 Ville-Veikko Helppi Technical Product Manager [email protected] The Powerful and Comprehensive API for Mobile App Development and Testing W E B I N A R

Upload: bitbar

Post on 16-Jul-2015

1.360 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

20 January 2015

Ville-Veikko HelppiTechnical Product Manager

[email protected]

The Powerful and

Comprehensive API for Mobile

App Development and Testing

W E B I N A R

Page 2: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 3: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

The Characteristics of Great

Application Programming

Interface

Page 4: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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?

Page 5: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 6: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

APIs Are Not Only for Services!

Page 7: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

The Manual Flow

Application

Results

Logs, outputs, data

Screenshots

Page 8: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 9: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

The Basics of

Communication Mechanisms

Page 10: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

For example:

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

api&grant_type=password&[email protected]

m&password=P4s$w0rd&parameters=more

The Basics

Page 11: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 12: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Requests and Responses

Page 13: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 14: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 15: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Access via Comprehensive API

Page 16: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 17: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Authentication

Page 18: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Authentication

Page 19: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Authentication

Page 20: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

SEND Header=Accept: application/json

client_id=testdroid_cloud_api

grant_type=password

[email protected]

password=XXXXXXXX

CURL:

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

api&grant_type=password&[email protected]&

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

Authentication

Page 21: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Projects and Managing Those

via API

Page 22: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get List of Projects

Page 23: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get List of Projects

Page 24: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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>"

Page 25: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Create a Project

Page 26: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Create a Project

Page 27: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 28: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Update a Project

Page 29: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Update a Project

Page 30: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 31: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Upload an App

Page 32: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Upload an App

Page 33: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 34: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Start a New Test Run

Page 35: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Start a New Test Run

Page 36: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 37: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Upload w/Python

Page 38: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get Results from Testdroid

Cloud via API

Page 39: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get Details of Test Run

Page 40: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get Details of Test Run

Page 41: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 42: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get Device Run Logs

Page 43: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get Device Run Logs

Page 44: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 45: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get Device Run Performance

Page 46: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get Device Run Performance

Page 47: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 48: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get Screenshots

Page 49: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Get Screenshots

Page 50: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 51: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Hands-on - Let's cURL!

Page 52: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 53: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

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

Page 54: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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

Page 55: Testdroid: The Powerful and Comprehensive API for Mobile App Development and Testing

© 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