Protractoring non Angular sites

Testing Tools

  • Node
  • Selenium
  • CoffeeScript
  • Protractor

Why protractor?

  • Wraps WebDriver
  • Simplifies async flow
  • Clear API
  • Supports non angular
  • Configurable
  • Multi browser
  • Easy to use
  • JS familiar

Setup

Write a test

describe 'Protractor Demo App', ->
  it 'should have a title', ->
    browser.get 'http://juliemr.github.io/protractor-demo/'

    expect(browser.getTitle()).toEqual 'Super Calculator'
npm install -g protractor
webdriver-manager update
webdriver-manager start

# http://localhost:4444/wd/hub

Disable Angular

exports.config = {
  // ...
  onPrepare: function() {
    global.dv = browser.driver;
    global.isAngularSite = function(flag) {
      browser.ignoreSynchronization = !flag;
    };
    isAngularSite(false);
  },
  // ...
};

Run

protractor protractor.conf.js

Page Objects

class Homepage
    constructor: () ->
        @nameInput = element By.id('nameInput')
        @greeting = element By.xpath('//*[@id="greeting"]')

    get = ->
        browser.get 'http://mysite.com'

    setName = (name) ->
        @nameInput.sendKeys name

module.exports = Homepage

Resources

Protractor

By Andrew Dacenko

Protractor

  • 946