Skip to content

Commit aca7a3e

Browse files
committed
Implementing ability to set proxy in Options classes
1 parent aca20bc commit aca7a3e

File tree

6 files changed

+37
-0
lines changed

6 files changed

+37
-0
lines changed

java/client/src/org/openqa/selenium/chrome/ChromeOptions.java

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.openqa.selenium.Capabilities;
3333
import org.openqa.selenium.MutableCapabilities;
3434
import org.openqa.selenium.PageLoadStrategy;
35+
import org.openqa.selenium.Proxy;
3536
import org.openqa.selenium.SessionNotCreatedException;
3637
import org.openqa.selenium.UnexpectedAlertBehaviour;
3738
import org.openqa.selenium.remote.BrowserType;
@@ -242,6 +243,11 @@ public ChromeOptions setHeadless(boolean headless) {
242243
return this;
243244
}
244245

246+
public ChromeOptions setProxy(Proxy proxy) {
247+
setCapability(CapabilityType.PROXY, proxy);
248+
return this;
249+
}
250+
245251
/**
246252
* Returns DesiredCapabilities for Chrome with these options included as
247253
* capabilities. This does not copy the options. Further changes will be

java/client/src/org/openqa/selenium/edge/EdgeOptions.java

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.openqa.selenium.Capabilities;
2525
import org.openqa.selenium.MutableCapabilities;
2626
import org.openqa.selenium.Platform;
27+
import org.openqa.selenium.Proxy;
2728
import org.openqa.selenium.remote.BrowserType;
2829
import org.openqa.selenium.remote.CapabilityType;
2930

@@ -76,6 +77,11 @@ public void setPageLoadStrategy(String strategy) {
7677
setCapability(PAGE_LOAD_STRATEGY, Objects.requireNonNull(strategy));
7778
}
7879

80+
public EdgeOptions setProxy(Proxy proxy) {
81+
setCapability(CapabilityType.PROXY, proxy);
82+
return this;
83+
}
84+
7985
/**
8086
* Returns DesiredCapabilities for Edge with these options included as capabilities. This does not
8187
* copy the options. Further changes will be reflected in the returned capabilities.

java/client/src/org/openqa/selenium/firefox/FirefoxOptions.java

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.openqa.selenium.Capabilities;
3333
import org.openqa.selenium.MutableCapabilities;
3434
import org.openqa.selenium.PageLoadStrategy;
35+
import org.openqa.selenium.Proxy;
3536
import org.openqa.selenium.UnexpectedAlertBehaviour;
3637
import org.openqa.selenium.WebDriverException;
3738
import org.openqa.selenium.firefox.internal.ProfilesIni;
@@ -296,6 +297,11 @@ public FirefoxOptions setHeadless(boolean headless) {
296297
return this;
297298
}
298299

300+
public FirefoxOptions setProxy(Proxy proxy) {
301+
setCapability(CapabilityType.PROXY, proxy);
302+
return this;
303+
}
304+
299305
@Override
300306
public void setCapability(String key, Object value) {
301307
switch (key) {

java/client/src/org/openqa/selenium/ie/InternetExplorerOptions.java

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.openqa.selenium.MutableCapabilities;
4545
import org.openqa.selenium.PageLoadStrategy;
4646
import org.openqa.selenium.Platform;
47+
import org.openqa.selenium.Proxy;
4748
import org.openqa.selenium.UnexpectedAlertBehaviour;
4849
import org.openqa.selenium.internal.ElementScrollBehavior;
4950
import org.openqa.selenium.remote.BrowserType;
@@ -229,6 +230,11 @@ public InternetExplorerOptions setUnhandledPromptBehaviour(UnexpectedAlertBehavi
229230
return amend(UNHANDLED_PROMPT_BEHAVIOUR, behaviour);
230231
}
231232

233+
public InternetExplorerOptions setProxy(Proxy proxy) {
234+
setCapability(CapabilityType.PROXY, proxy);
235+
return this;
236+
}
237+
232238
private InternetExplorerOptions amend(String optionName, Object value) {
233239
setCapability(optionName, value);
234240
return this;

java/client/src/org/openqa/selenium/opera/OperaOptions.java

+7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import com.google.common.io.Files;
2929

3030
import org.openqa.selenium.MutableCapabilities;
31+
import org.openqa.selenium.Proxy;
3132
import org.openqa.selenium.WebDriverException;
33+
import org.openqa.selenium.remote.CapabilityType;
3234

3335
import java.io.File;
3436
import java.io.IOException;
@@ -199,6 +201,11 @@ public Object getExperimentalOption(String name) {
199201
return experimentalOptions.get(checkNotNull(name));
200202
}
201203

204+
public OperaOptions setProxy(Proxy proxy) {
205+
setCapability(CapabilityType.PROXY, proxy);
206+
return this;
207+
}
208+
202209
@Override
203210
public Map<String, ?> asMap() {
204211
Map<String, Object> toReturn = new TreeMap<>();

java/client/src/org/openqa/selenium/safari/SafariOptions.java

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.openqa.selenium.Capabilities;
2323
import org.openqa.selenium.MutableCapabilities;
2424
import org.openqa.selenium.Platform;
25+
import org.openqa.selenium.Proxy;
2526
import org.openqa.selenium.WebDriverException;
2627
import org.openqa.selenium.remote.CapabilityType;
2728

@@ -158,6 +159,11 @@ public SafariOptions setUseTechnologyPreview(boolean useTechnologyPreview) {
158159
return this;
159160
}
160161

162+
public SafariOptions setProxy(Proxy proxy) {
163+
setCapability(CapabilityType.PROXY, proxy);
164+
return this;
165+
}
166+
161167
// Getters
162168

163169
/**

0 commit comments

Comments
 (0)