Skip to content

Instantly share code, notes, and snippets.

@knubie
Last active August 29, 2015 14:11
Show Gist options
  • Save knubie/980597d2a14251099786 to your computer and use it in GitHub Desktop.
Save knubie/980597d2a14251099786 to your computer and use it in GitHub Desktop.
Node vs Ruby Selenium testing

Node vs Ruby Selenium testing


Tools:
  Ruby:
    - Rspec - Test runner
    - Capybara - browser control bindings / assertion library
    - Selenium - browser abstraction and running factory
  Node:
    - Mocha - Test runner
    - Chai - Assertion library
    - Webdriverio - browser control bindings
    - Selenium - browser abstraction and running factory

Set up


Ruby:

require 'capybara'
require 'capybara/rspec'

Capybara.configure do |config|
  config.run_server = false
  config.default_driver = :selenium
  config.app_host = 'http://google.com'
end

describe 'Check homepage' do
  it 'should see the correct title' do
    page.click 'Search'
    expect(page).to have_title "my title"
  end
end

Node:

var page = require('webdriverio');
var expect = require('chai').expect;

page.init()
    .url('http://google.com');
    
describe('Check homepage', function(){
  it('should see the correct title', function(done) {
    page.click('Search', function(err, res) {
      page.getTitle(function(err, title) {
        expect(title).to.have.string('Search Page');
      });
    });
  });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment