Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Protractor e2e Cheatsheet (CoffeeScript)
browser.get "/phones" # navigate to /phones URL
input.clear() # clear text input field
expect(browser.getTitle()).toMatch 'My Google Photo Gallery'
expect(browser.getCurrentUrl()).toMatch "/phones$"
# Find by...
# --------------
# ... by CSS id or class
expect(element(By.id("svapp-previous-slide-link")).getText()).toBe "Previous"
expect(element(By.id("svapp-current-slide-image")).getAttribute('src')).toMatch /\/data\/presentations\/1\/images\/Slide1.JPGX/
expect(element(By.css(".svapp-current-slide")).getText()).toBe "My Slide"
# ... element with {{scopeVar}} syntax.
element(By.binding("person.name")).getText().then (name) ->
expect(name).toBe "Foo"
return
# ... element with ng-bind="scopeVar" syntax.
expect(element(By.binding("person.email")).getText()).toBe "foo@bar.com"
# ... by model
input = element(By.model("person.name"))
input.sendKeys "123"
expect(input.getAttribute("value")).toBe "Foo123"
expect(element(By.binding("person.email")).getText()).toBe "foo@bar.com"
# ... by repeater
expect(element.all(By.repeater("phone in phones")).count()).toBe 8
expect(element.all(By.repeater("phone in phones").column("phone.name")).first().getText()).toBe "Motorola XOOM"
# Select option in dropdown list
# -----------------------------
<select ng-model="orderProp">
<option value="name">Alphabetical</option>
<option value="age">Newest</option>
</select>
element(By.model('orderProp')).$('[value="age"]').click()
# Check image is present
expect(element(By.id('recaptcha_image')).isPresent()).toBe(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.