Skip to content

Instantly share code, notes, and snippets.

@benshimmin
Last active December 21, 2015 20:49
Show Gist options
  • Save benshimmin/6364407 to your computer and use it in GitHub Desktop.
Save benshimmin/6364407 to your computer and use it in GitHub Desktop.
Selenium and Jasmine and other such fun
var webdriver = require("selenium-webdriver");
var driver = new webdriver.Builder().
usingServer("http://localhost:4444/wd/hub").
withCapabilities(webdriver.Capabilities.phantomjs()).
build();
describe("Get the title of the Google homepage", function() {
it("should be 'Google'", function(done) {
driver.get("http://google.com/");
driver.getTitle().then(function(title) {
expect(title).toBe("Google");
done();
});
});
it("should be 'Googooole'", function(done) {
driver.get("http://google.com/");
driver.getTitle().then(function(title) {
expect(title).toBe("Googooole");
done();
});
});
});
// store a reference to the current runner's finish callback;
// we can effectively call this as our final teardown, after all
// tests are complete
var cb = jasmine.getEnv().currentRunner().finishCallback;
jasmine.getEnv().currentRunner().finishCallback = function() {
cb.apply(this, arguments);
driver.quit();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment