Skip to content

Instantly share code, notes, and snippets.

Last active September 27, 2020 00:03
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
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("svapp-previous-slide-link")).getText()).toBe "Previous"
expect(element("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("")).getText().then (name) ->
expect(name).toBe "Foo"
# ... element with ng-bind="scopeVar" syntax.
expect(element(By.binding("")).getText()).toBe ""
# ... by model
input = element(By.model(""))
input.sendKeys "123"
expect(input.getAttribute("value")).toBe "Foo123"
expect(element(By.binding("")).getText()).toBe ""
# ... by repeater
expect(element.all(By.repeater("phone in phones")).count()).toBe 8
expect(element.all(By.repeater("phone in phones").column("")).first().getText()).toBe "Motorola XOOM"
# Select option in dropdown list
# -----------------------------
<select ng-model="orderProp">
<option value="name">Alphabetical</option>
<option value="age">Newest</option>
# Check image is present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment