Last active
December 21, 2015 20:49
-
-
Save benshimmin/6364407 to your computer and use it in GitHub Desktop.
Selenium and Jasmine and other such fun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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