1
0
Fork 0
mirror of https://github.com/teampoltergeist/poltergeist.git synced 2022-11-09 12:05:00 -05:00

Add ability to set proxy at runtime (needs test coverage)

This commit is contained in:
Dmitry Vorotilin 2016-03-11 18:05:42 +03:00
parent ea8bb984ce
commit 386faae041
6 changed files with 24 additions and 0 deletions

View file

@ -1,5 +1,8 @@
### Next release ###
#### Features ####
* Added ability to set proxy at runtime (Dmitry Vorotilin)
### 1.9.0 ###
#### Features ####

View file

@ -110,6 +110,7 @@ and the following optional features:
* `page.driver.scroll_to(left, top)`
* `page.driver.basic_authorize(user, password)`
* `element.native.send_keys(*keys)`
* `page.driver.set_proxy(ip, port, type, user, password)`
* window API
* cookie handling
* drag-and-drop

View file

@ -260,6 +260,13 @@ module Capybara::Poltergeist
command('clear_network_traffic')
end
def set_proxy(ip, port, type, user, password)
args = [ip, port, type]
args << user if user
args << password if password
command('set_proxy', *args)
end
def equals(page_id, id, other_id)
command('equals', page_id, id, other_id)
end

View file

@ -400,6 +400,10 @@ class Poltergeist.Browser
@currentPage.clearNetworkTraffic()
@current_command.sendResponse(true)
set_proxy: (ip, port, type, user, password) ->
phantom.setProxy(ip, port, type, user, password)
@current_command.sendResponse(true)
get_headers: ->
@current_command.sendResponse(@currentPage.getCustomHeaders())

View file

@ -549,6 +549,11 @@ Poltergeist.Browser = (function() {
return this.current_command.sendResponse(true);
};
Browser.prototype.set_proxy = function(ip, port, type, user, password) {
phantom.setProxy(ip, port, type, user, password);
return this.current_command.sendResponse(true);
};
Browser.prototype.get_headers = function() {
return this.current_command.sendResponse(this.currentPage.getCustomHeaders());
};

View file

@ -224,6 +224,10 @@ module Capybara::Poltergeist
browser.clear_network_traffic
end
def set_proxy(ip, port, type = "http", user = nil, password = nil)
browser.set_proxy(ip, port, type, user, password)
end
def headers
browser.get_headers
end