Skip to content

Instantly share code, notes, and snippets.

@samccone
Created March 17, 2015 23:11
Show Gist options
  • Save samccone/c916568e959ccf68acfa to your computer and use it in GitHub Desktop.
Save samccone/c916568e959ccf68acfa to your computer and use it in GitHub Desktop.
simple selenium mocha test
var assert = require("assert");
var webdriver = require("selenium-webdriver");
describe("testing javascript in the browser", function() {
beforeEach(function() {
this.browser = new webdriver.Builder()
.withCapabilities({
browserName: "chrome"
}).build();
return this.browser.get("http://localhost:8000/page/index.html");
});
afterEach(function() {
return this.browser.quit();
});
it("should handle clicking on a headline", function(done) {
var headline = this.browser.findElement(webdriver.By.css('h1'));
headline.click();
headline.getText().then(function(txt) {
assert.equal(txt, "awesome");
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment