Skip to content

Instantly share code, notes, and snippets.

@misaxi
Last active August 29, 2015 13:55
Show Gist options
  • Save misaxi/8701339 to your computer and use it in GitHub Desktop.
Save misaxi/8701339 to your computer and use it in GitHub Desktop.
A base Page object class which wraps
class Page
constructor: ->
# this is singleton
@ptor = protractor.getInstance()
get: (relativeUrl, ignoreSync) ->
# we want to ignore sync if the
# page does not use AngularJS
@ptor.ignoreSynchronization = ignoreSync or false
@ptor.get @ptor.baseUrl + relativeUrl
element: (locator, container) ->
if container
container.findElement locator
else
@ptor.findElement locator
byId: (id, container) ->
@element protractor.By.id(id), container
byCss: (css, container) ->
@element protractor.By.css(css), container
byText: (text, container) ->
xpath = "//*[text()[contains(.,'#{text}')]]"
@element protractor.By.xpath(xpath), container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment