diff --git a/sample-code/examples/node/ios-selenium-webdriver-bridge.js b/sample-code/examples/node/ios-selenium-webdriver-bridge.js index 202b1fc44..0041a7c86 100644 --- a/sample-code/examples/node/ios-selenium-webdriver-bridge.js +++ b/sample-code/examples/node/ios-selenium-webdriver-bridge.js @@ -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 */ diff --git a/sample-code/examples/node/protractor-bridge/conf.js b/sample-code/examples/node/protractor-bridge/conf.js new file mode 100644 index 000000000..74c6304e2 --- /dev/null +++ b/sample-code/examples/node/protractor-bridge/conf.js @@ -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; \ No newline at end of file diff --git a/sample-code/examples/node/protractor-bridge/example_spec.js b/sample-code/examples/node/protractor-bridge/example_spec.js new file mode 100644 index 000000000..9a1f3ca68 --- /dev/null +++ b/sample-code/examples/node/protractor-bridge/example_spec.js @@ -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); + }); + + }); +});