added protractor bridge example

This commit is contained in:
sebv
2014-07-03 22:26:27 +08:00
parent d4416339d8
commit 10250698b0
3 changed files with 91 additions and 1 deletions

View File

@@ -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
*/

View 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;

View 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);
});
});
});