Skip to content
This repository was archived by the owner on Jul 30, 2022. It is now read-only.

example(protractor-appium):adding an example for protractor with appi… #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions protractor-appium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Appium setup:
============

1. For [MAC](https://github.com/isonic1/appium-workshop/blob/master/Appium%20Mac%20Installation%20Instructions.md)
2. For [WINDOWS](https://github.com/isonic1/appium-workshop/blob/master/Appium%20Windows%20Installation%20Instructions.md)

Setup
=====

```
npm install
```

- Installs the Protractor and Appium node module

Start Appium Server
====================

```
npm start-appium
```


Testing with JavaScript
=======================

```
npm test
```

- Runs the test in Chrome browser first followed by Hybrid application

Files
=====

```
/protractor-appium/
|- app
|- example-browser
|- example-hybridapps
```
Binary file added protractor-appium/app/calculator.apk
Binary file not shown.
8 changes: 8 additions & 0 deletions protractor-appium/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var baseUrl = (process.env.BASE_URL || 'http://localhost:8080');
var url = baseUrl;
if (baseUrl !== 'http://localhost:8080') {
url += '/protractor-cookbook';
} else {
url = "http://10.0.2.2:8080"; // cannot access the demo app inside mobile browser using "http://localhost". refer https://developer.android.com/studio/run/emulator-networking.
}
exports.url = url;
15 changes: 15 additions & 0 deletions protractor-appium/example-browser/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var env = require('../environment');

exports.config = {
specs: ["../spec.js"],
seleniumAddress : "http://0.0.0.0:4723/wd/hub",
capabilities : {
deviceName : 'emulator-5554', // replace it with your device name
platformName : 'Android',
browserName : 'Chrome',
noReset : true,
},
onPrepare :function () {
browser.get(env.url + "/ng1/calculator");
}
};
15 changes: 15 additions & 0 deletions protractor-appium/example-hybridapps/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var env = require('../environment');

exports.config = {
specs: ["../spec.js"],
seleniumAddress : "http://0.0.0.0:4723/wd/hub",
capabilities : {
deviceName : 'emulator-5554', // replace it with your device name
platformName : 'Android',
autoWebview : true,
autoWebviewTimeout: 10000,
autoAcceptAlerts: 'true',
app : __dirname+"/../app/calculator.apk",
browserName : '',
},
};
19 changes: 19 additions & 0 deletions protractor-appium/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "protractor-appium-hybridapps",
"version": "1.0.0",
"description": "a protractor with appium example",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"start-appium": "appium",
"test": "protractor example-browser/config.js && protractor example-hybridapps/config.js"
},
"author": "Sudharsan Selvaraj <sudharsanselvaraj.c@gmail.com> (https://github.com/sudharsan-selvaraj/)",
"license": "ISC",
"dependencies": {
"appium": "^1.8.0",
"protractor": "^5.3.1"
}
}
48 changes: 48 additions & 0 deletions protractor-appium/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

describe('slow calculator', () => {


it('should add numbers', () => {
element(by.id('gobutton')).click();

element(by.model('first')).sendKeys(4);
element(by.model('second')).sendKeys(5);
element(by.id('gobutton')).click();

expect(element(by.binding('latest')).getText()).toEqual('9');
});

describe('memory', () => {
var first, second, goButton;
beforeEach(function () {
browser.driver.navigate().refresh();
first = element(by.model('first'));
second = element(by.model('second'));
goButton = element(by.id('gobutton'));
});

it('should start out with an empty memory', () => {
var memory =
element.all(by.repeater('result in memory'));

expect(memory.count()).toEqual(0);
});

it('should fill the memory with past results', () => {
first.sendKeys(1);
second.sendKeys(1);
goButton.click();

first.sendKeys(10);
second.sendKeys(20);
goButton.click();

var memory = element.all(by.repeater('result in memory').column('result.value'));
memory.then((arr) => {
expect(arr.length).toEqual(2);
expect(arr[0].getText()).toEqual('30'); // 10 + 20 = 30
expect(arr[1].getText()).toEqual('2'); // 1 + 1 = 2
});
});
});
});
2 changes: 1 addition & 1 deletion testapp/ng1/calculator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Super Calculator</title>
</head>
<body class="ng-cloak">
<div ng-controller="CalcCtrl" class="container">
<div ng-controller="CalcCtrl" class="container-fluid">
<div>
<h3>Super Calculator</h3>
<form class="form-inline">
Expand Down