private URL buildURL(URL url) throws UnsupportedEncodingException, MalformedURLException { String fullURLString = url.toString(); fullURLString += "/runner"; boolean hasFirstParameter = false; if (overrideURL != null) { fullURLString += "?url=" + URLEncoder.encode(overrideURL, "UTF-8"); hasFirstParameter = true; } else if (configuration.getTestURL() != null) { fullURLString += "?url=" + URLEncoder.encode(configuration.getTestURL().toString(), "UTF-8"); hasFirstParameter = true; } if (remoteBrowser != null) { fullURLString += (hasFirstParameter ? "&" : "?"); fullURLString += "browserId=" + remoteBrowser.getId(); } return new URL(fullURLString); }