@@ -91,6 +91,20 @@ public static org.openqa.selenium.Proxy createSeleniumProxy(BrowserUpProxy brows
9191 return createSeleniumProxy (new InetSocketAddress (connectableAddress , browserUpProxy .getPort ()));
9292 }
9393
94+ /**
95+ * Creates a Selenium Proxy object from the BrowserUpProxy instance, using the specified hostnameOrAddress as the Selenium Proxy object's
96+ * proxy address. Determines the port using {@link BrowserUpProxy#getPort()}. The BrowserUpProxy must be started.
97+ *
98+ * @param browserUpProxy started BrowserUpProxy instance to read the port from
99+ * @param hostnameOrAddress the hostnameOrAddress or the String form of the address the Selenium Proxy will use to
100+ * reach its proxy server.
101+ * @return a Selenium Proxy instance, configured to use the BrowserUpProxy instance as its proxy server
102+ * @throws java.lang.IllegalStateException if the proxy has not been started.
103+ */
104+ public static org .openqa .selenium .Proxy createSeleniumProxy (BrowserUpProxy browserUpProxy , String hostnameOrAddress ) {
105+ return createSeleniumProxy (hostnameOrAddress , browserUpProxy .getPort ());
106+ }
107+
94108 /**
95109 * Creates a Selenium Proxy object using the specified connectableAddressAndPort as the HTTP proxy server.
96110 *
@@ -99,10 +113,22 @@ public static org.openqa.selenium.Proxy createSeleniumProxy(BrowserUpProxy brows
99113 * @return a Selenium Proxy instance, configured to use the specified address and port as its proxy server
100114 */
101115 public static org .openqa .selenium .Proxy createSeleniumProxy (InetSocketAddress connectableAddressAndPort ) {
116+ return createSeleniumProxy (connectableAddressAndPort .getHostString (), connectableAddressAndPort .getPort ());
117+ }
118+
119+ /**
120+ * Creates a Selenium Proxy object using the specified connectableAddressAndPort as the HTTP proxy server.
121+ *
122+ * @param hostnameOrAddress the hostnameOrAddress or the String form of the address the Selenium Proxy will use to
123+ * reach its proxy server.
124+ * @param port the port the Selenium Proxy will use to reach its proxy server.
125+ * @return a Selenium Proxy instance, configured to use the specified address and port as its proxy server
126+ */
127+ public static org .openqa .selenium .Proxy createSeleniumProxy (String hostnameOrAddress , int port ) {
102128 Proxy proxy = new Proxy ();
103129 proxy .setProxyType (Proxy .ProxyType .MANUAL );
104130
105- String proxyStr = String .format ("%s:%d" , connectableAddressAndPort . getHostString (), connectableAddressAndPort . getPort () );
131+ String proxyStr = String .format ("%s:%d" , hostnameOrAddress , port );
106132 proxy .setHttpProxy (proxyStr );
107133 proxy .setSslProxy (proxyStr );
108134
0 commit comments