Source:
public BrowserStackDriver createInstance(WebDriverConfiguration configuration) { try { Capabilities capabilities = configuration.getCapabilities(); String url = (String) capabilities.getCapability(URL); String accessKey = null; if (isEmpty(url)) { String username = (String) capabilities.getCapability(USERNAME); accessKey = (String) capabilities.getCapability(ACCESS_KEY); if (isEmpty(accessKey)) { accessKey = (String) capabilities.getCapability("automate.key"); } if (isEmpty(username) || isEmpty(accessKey)) { log.severe( "You have to specify either an username and an access.key or the whole url in your arquillian descriptor"); return null; } else { url = "http://" + username + ":" + accessKey + "@hub.browserstack.com/wd/hub"; } } boolean isSetBrowserStackLocal = capabilities.is(BROWSERSTACK_LOCAL); boolean isSetBrowserStackLocalManaged = capabilities.is(BROWSERSTACK_LOCAL_MANAGED); if (isSetBrowserStackLocal && isSetBrowserStackLocalManaged && (!isEmpty(accessKey) || !isEmpty(url))) { if (isEmpty(accessKey)) { accessKey = url.substring(url.lastIndexOf(":") + 1, url.indexOf("@")); } String additionalArgs = (String) capabilities.getCapability(BROWSERSTACK_LOCAL_ARGS); String localBinary = (String) capabilities.getCapability(BROWSERSTACK_LOCAL_BINARY); BrowserStackLocalRunner.createBrowserStackLocalInstance() .runBrowserStackLocal(accessKey, additionalArgs, localBinary); } return new BrowserStackDriver(new URL(url), capabilities, isSetBrowserStackLocal, isSetBrowserStackLocalManaged); } catch (MalformedURLException e) { e.printStackTrace(); } return null; }

Target:
public BrowserStackDriver createInstance(WebDriverConfiguration configuration) { Capabilities capabilities = configuration.getCapabilities(); String url = (String) capabilities.getCapability(URL); String accessKey = null; if (Utils.isNullOrEmpty(url)) { String username = (String) capabilities.getCapability(USERNAME); accessKey = (String) capabilities.getCapability(ACCESS_KEY); if (Utils.isNullOrEmpty(accessKey)) { accessKey = (String) capabilities.getCapability("automate.key"); } if (Utils.isNullOrEmpty(username) || Utils.isNullOrEmpty(accessKey)) { throw new IllegalArgumentException( "You have to specify either an username and an access.key or the whole url in your arquillian descriptor"); } else { url = "http://" + username + ":" + accessKey + "@hub.browserstack.com/wd/hub"; } } try { URL browserStackUrl = new URL(url); boolean isSetBrowserStackLocal = capabilities.is(BROWSERSTACK_LOCAL); boolean isSetBrowserStackLocalManaged = capabilities.is(BROWSERSTACK_LOCAL_MANAGED); if (isSetBrowserStackLocal && isSetBrowserStackLocalManaged) { if (Utils.isNullOrEmpty(accessKey)) { accessKey = url.substring(url.lastIndexOf(":") + 1, url.indexOf("@")); } String additionalArgs = (String) capabilities.getCapability(BROWSERSTACK_LOCAL_ARGS); String localBinary = (String) capabilities.getCapability(BROWSERSTACK_LOCAL_BINARY); BrowserStackLocalRunner.getBrowserStackLocalInstance().runBrowserStackLocal(accessKey, additionalArgs, localBinary); } return new BrowserStackDriver(browserStackUrl, capabilities, isSetBrowserStackLocal, isSetBrowserStackLocalManaged); } catch (MalformedURLException e) { throw new IllegalArgumentException( "The BrowserStack url: " + url + " has been detected as a malformed URL. ", e); } }