mirror of
https://github.com/appium/appium.git
synced 2026-02-09 19:28:48 -06:00
added protractor bridge example
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
However it is possible to attach an existing selenium-webdriver session to
|
||||
a wd browser instance as below.
|
||||
|
||||
prerequisite:
|
||||
prerequisites:
|
||||
npm install selenium-webdriver
|
||||
*/
|
||||
|
||||
|
||||
43
sample-code/examples/node/protractor-bridge/conf.js
Normal file
43
sample-code/examples/node/protractor-bridge/conf.js
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
The appium specific methods are not yet implemented by selenium-webdriver,
|
||||
and therefore not available in Protractor. However it is possible to attach
|
||||
an existing Protractor session to a wd browser instance as below.
|
||||
|
||||
prerequisites:
|
||||
npm install protractor
|
||||
npm install -g protractor
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var wd = require('wd'),
|
||||
wdBridge = require('wd-bridge')(wd),
|
||||
_ = require('underscore');
|
||||
|
||||
// An example configuration file.
|
||||
var config = {
|
||||
seleniumAddress: 'http://localhost:4723/wd/hub',
|
||||
|
||||
// Capabilities to be passed to the webdriver instance.
|
||||
capabilities: _({}).chain()
|
||||
.extend(require("../helpers/caps").ios71)
|
||||
.extend({'browserName': 'safari'})
|
||||
.omit('app').value(),
|
||||
// Spec patterns are relative to the current working directly when
|
||||
// protractor is called.
|
||||
specs: ['example_spec.js'],
|
||||
|
||||
// Options to be passed to Jasmine-node.
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000
|
||||
},
|
||||
|
||||
// configuring wd in onPrepare
|
||||
onPrepare: function () {
|
||||
wdBridge.initFromProtractor(config);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
exports.config = config;
|
||||
47
sample-code/examples/node/protractor-bridge/example_spec.js
Normal file
47
sample-code/examples/node/protractor-bridge/example_spec.js
Normal file
@@ -0,0 +1,47 @@
|
||||
/* global describe, it, browser, wdBrowser, element, by, expect, beforeEach */
|
||||
"use strict";
|
||||
|
||||
describe('angularjs homepage', function () {
|
||||
it('should greet the named user', function () {
|
||||
browser.get('http://www.angularjs.org');
|
||||
|
||||
element(by.model('yourName')).sendKeys('Julie');
|
||||
|
||||
var greeting = element(by.binding('yourName'));
|
||||
|
||||
expect(greeting.getText()).toEqual('Hello Julie!');
|
||||
});
|
||||
|
||||
describe('todo list', function () {
|
||||
var todoList;
|
||||
|
||||
beforeEach(function () {
|
||||
browser.get('http://www.angularjs.org');
|
||||
|
||||
todoList = element.all(by.repeater('todo in todos'));
|
||||
});
|
||||
|
||||
it('should list todos', function () {
|
||||
expect(todoList.count()).toEqual(2);
|
||||
expect(todoList.get(1).getText()).toEqual('build an angular app');
|
||||
});
|
||||
|
||||
it('should add a todo', function () {
|
||||
var addTodo = element(by.model('todoText'));
|
||||
var addButton = element(by.css('[value="add"]'));
|
||||
|
||||
addTodo.sendKeys('write a protractor test');
|
||||
addButton.click();
|
||||
|
||||
expect(todoList.count()).toEqual(3);
|
||||
expect(todoList.get(2).getText()).toEqual('write a protractor test');
|
||||
});
|
||||
|
||||
it('should be able to use wdBrowser ', function (done) {
|
||||
wdBrowser.title().then(function (title) {
|
||||
expect(title).toEqual('AngularJS — Superheroic JavaScript MVW Framework');
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user