java.net.URISyntaxException : Expected authority at index 7: http://

标签 java selenium

我遇到错误:

Caused by: java.net.URISyntaxException: Expected authority at index 7: http://

对于下面的代码:

try 
{
    return new RemoteWebDriver(new URL("http://" + username + ":" + authkey +"@hub.crossbrowsertesting.com:80/wd/hub"), caps);
} 
catch (MalformedURLException e) 
{
    // TODO Auto-generated catch block
    e.printStackTrace();
    return null;
 }

堆栈跟踪:

Driver info: driver.version: RemoteWebDriver at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:155) at abc.testcase.LoginForm2.main(LoginForm2.java:45) Caused by: org.apache.http.client.ClientProtocolException at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55) at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:142) at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:88) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:108) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:64) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) ... 4 more Caused by: org.apache.http.HttpException: Cannot convert host to URI: http:// at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:77) at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:77) at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:124) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:183) ... 12 more Caused by: java.net.URISyntaxException: Expected authority at index 7: http:// at java.net.URI$Parser.fail(URI.java:2848) at java.net.URI$Parser.failExpecting(URI.java:2854) at java.net.URI$Parser.parseHierarchical(URI.java:3102) at java.net.URI$Parser.parse(URI.java:3053) at java.net.URI.(URI.java:588) at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:75) ... 15 more

请帮忙!

最佳答案

通过将 @ 编码为 %40 就解决了错误

关于java.net.URISyntaxException : Expected authority at index 7: http://,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44433506/

相关文章:

java - 不同 Java 映射类型的每个映射值的相对内存开销是多少

java - 如何通过DAO更新mysql中实体的ID?

java foreach数据库列表值

java - 不寻常的通用语法 : Arrays. <String>asList(...)

java - 在 Selenium 项目中,与 `new FirefoxOptions()`相比,如何使用 `DesiredCapabilities.firefox()`寻址日志信息更为可取

java - 如何使用 selenium Web 驱动程序自动执行对话框消息的测试用例

node.js - 为什么我会得到之前的选项卡 url?

java - 为什么下面的代码可以编译运行成功?

angularjs - browser.debugger() 不会暂停浏览器

python - Selenium 请求的 HTTP header 中缺少 Referer