lib/capybara/poltergeist/client/browser.coffee in poltergeist-1.4.1 vs lib/capybara/poltergeist/client/browser.coffee in poltergeist-1.5.0
- old
+ new
@@ -119,10 +119,13 @@
this.sendResponse this.node(page_id, id).allText()
visible_text: (page_id, id) ->
this.sendResponse this.node(page_id, id).visibleText()
+ delete_text: (page_id, id) ->
+ this.sendResponse this.node(page_id, id).deleteText()
+
attribute: (page_id, id, name) ->
this.sendResponse this.node(page_id, id).getAttribute(name)
value: (page_id, id) ->
this.sendResponse this.node(page_id, id).value()
@@ -248,10 +251,19 @@
scroll_to: (left, top) ->
@page.setScrollPosition(left: left, top: top)
this.sendResponse(true)
+ send_keys: (page_id, id, keys) ->
+ # Programmatically generated focus doesn't work for `sendKeys`.
+ # That's why we need something more realistic like user behavior.
+ this.node(page_id, id).mouseEvent('click')
+ for sequence in keys
+ key = if sequence.key? then @page.native.event.key[sequence.key] else sequence
+ @page.sendEvent('keypress', key)
+ this.sendResponse(true)
+
render_base64: (format, full, selector = null)->
this.set_clip_rect(full, selector)
encoded_image = @page.renderBase64(format)
this.sendResponse(encoded_image)
@@ -275,17 +287,25 @@
left: 0, top: 0, width: viewport.width, height: viewport.height
@page.setClipRect(rect)
dimensions
+ set_paper_size: (size) ->
+ @page.setPaperSize(size)
+ this.sendResponse(true)
+
resize: (width, height) ->
@page.setViewportSize(width: width, height: height)
this.sendResponse(true)
network_traffic: ->
this.sendResponse(@page.networkTraffic())
+ clear_network_traffic: ->
+ @page.clearNetworkTraffic()
+ this.sendResponse(true)
+
get_headers: ->
this.sendResponse(@page.getCustomHeaders())
set_headers: (headers) ->
# Workaround for https://code.google.com/p/phantomjs/issues/detail?id=745
@@ -321,10 +341,14 @@
cookies_enabled: (flag) ->
phantom.cookiesEnabled = flag
this.sendResponse(true)
+ set_http_auth: (user, password) ->
+ @page.setHttpAuth(user, password)
+ this.sendResponse(true)
+
set_js_errors: (value) ->
@js_errors = value
this.sendResponse(true)
set_debug: (value) ->
@@ -338,5 +362,13 @@
# NOOOOOOP!
# This command is purely for testing error handling
browser_error: ->
throw new Error('zomg')
+
+ go_back: ->
+ this.page.goBack() if this.page.canGoBack
+ this.sendResponse(true)
+
+ go_forward: ->
+ this.page.goForward() if this.page.canGoForward
+ this.sendResponse(true)