Forked from anonymous/promised-webdriver-example.js
Created
December 13, 2012 20:25
-
-
Save tlrobinson/4279483 to your computer and use it in GitHub Desktop.
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
# Waits for an element to be present, then returns it. | |
browser.waitForAndGetElementBy = (kind, value) -> | |
@["waitForElementBy#{kind}"](value, 5000) | |
.then => | |
@["elementBy#{kind}"](value) | |
browser.init(desired) | |
.then -> | |
browser.get "http://example.com/" | |
.then -> | |
browser.waitForAndGetElementBy "XPath", "//div[@id='some_id']/div/div/a" | |
.then (element) -> | |
browser.clickElement element | |
.then (element) -> | |
browser.waitForAndGetElementBy "CssSelector", 'iframe[src^="http://example.com/share"]' | |
.then (element) -> | |
browser.frame 0 | |
.then -> | |
browser.waitForAndGetElementBy "Name", "message" | |
.then (element) -> | |
browser.type element, "hello world" | |
.then -> | |
browser.waitForAndGetElementBy "ClassName", "share-button" | |
.then (element) -> | |
browser.clickElement element | |
.then -> | |
browser.windowHandles() | |
.then (handles) -> | |
browser.window "Log In | Facebook" | |
console.log handles | |
.then -> | |
browser.waitForAndGetElementBy "Id", "email" | |
.then (element) -> | |
browser.type element, FACEBOOK_USER_EMAIL | |
.then -> | |
browser.waitForAndGetElementBy "Id", "pass" | |
.then (element) -> | |
browser.type element, FACEBOOK_USER_PASSWORD | |
.then -> | |
browser.waitForAndGetElementBy "Id", "loginbutton" | |
.then (element) -> | |
browser.clickElement element | |
.then -> | |
console.log "Quitting" | |
browser.quit() | |
, (err) -> | |
console.log "Error: #{err}" | |
browser.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment