Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Commit

Permalink
Add Driver#refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jul 5, 2017
1 parent eb83083 commit 544d08a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/capybara/poltergeist/browser.rb
Expand Up @@ -391,6 +391,10 @@ def go_forward
command 'go_forward'
end

def refresh
command 'refresh'
end

def accept_confirm
command 'set_confirm_process', true
end
Expand Down
5 changes: 5 additions & 0 deletions lib/capybara/poltergeist/client/browser.coffee
Expand Up @@ -520,6 +520,11 @@ class Poltergeist.Browser
else
@current_command.sendResponse(false)

refresh: ->
@currentPage.state = 'wait_for_loading'
@currentPage.reload()
@_waitForHistoryChange()

set_url_whitelist: (wildcards...)->
@currentPage.urlWhitelist = (@_wildcardToRegexp(wc) for wc in wildcards)
@current_command.sendResponse(true)
Expand Down
6 changes: 6 additions & 0 deletions lib/capybara/poltergeist/client/compiled/browser.js
Expand Up @@ -715,6 +715,12 @@ Poltergeist.Browser = (function() {
}
};

Browser.prototype.refresh = function() {
this.currentPage.state = 'wait_for_loading';
this.currentPage.reload();
return this._waitForHistoryChange();
};

Browser.prototype.set_url_whitelist = function() {
var wc, wildcards;
wildcards = 1 <= arguments.length ? slice.call(arguments, 0) : [];
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/poltergeist/client/compiled/web_page.js
Expand Up @@ -7,7 +7,7 @@ Poltergeist.WebPage = (function() {

WebPage.CALLBACKS = ['onConsoleMessage', 'onError', 'onLoadFinished', 'onInitialized', 'onLoadStarted', 'onResourceRequested', 'onResourceReceived', 'onResourceError', 'onNavigationRequested', 'onUrlChanged', 'onPageCreated', 'onClosing'];

WebPage.DELEGATES = ['open', 'sendEvent', 'uploadFile', 'render', 'close', 'renderBase64', 'goBack', 'goForward'];
WebPage.DELEGATES = ['open', 'sendEvent', 'uploadFile', 'render', 'close', 'renderBase64', 'goBack', 'goForward', 'reload'];

WebPage.COMMANDS = ['currentUrl', 'find', 'nodeCall', 'documentSize', 'beforeUpload', 'afterUpload', 'clearLocalStorage'];

Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/poltergeist/client/web_page.coffee
Expand Up @@ -6,7 +6,7 @@ class Poltergeist.WebPage
'onClosing']

@DELEGATES = ['open', 'sendEvent', 'uploadFile', 'render', 'close',
'renderBase64', 'goBack', 'goForward']
'renderBase64', 'goBack', 'goForward', 'reload']

@COMMANDS = ['currentUrl', 'find', 'nodeCall', 'documentSize',
'beforeUpload', 'afterUpload', 'clearLocalStorage']
Expand Down
4 changes: 4 additions & 0 deletions lib/capybara/poltergeist/driver.rb
Expand Up @@ -361,6 +361,10 @@ def go_forward
browser.go_forward
end

def refresh
browser.refresh
end

def accept_modal(type, options = {})
case type
when :confirm
Expand Down

0 comments on commit 544d08a

Please sign in to comment.