我刚开始学习Selenium WebDriver。你能帮我解决以下问题吗? 我只是想打开的网站(我能够成功地打开浏览器,但导航得到了失败的)线程“main”中的异常org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class webdriverdemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
//Puts an Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Launch website
driver.navigate().to("http://www.calculator.net/");
//Maximize the browser
driver.manage().window().maximize();
}
}
我发现下面的错误:在线程“主要” 组织
例外。 openqa.selenium.remote.UnreachableBrowserException:不能 开始一个新的会话。可能的原因是服务器或浏览器启动失败的远程地址为无效的 。 构建信息:版本:'2.53.0',修订:'35ae25b',时间:'2016-03-15 17:00:58' 系统信息:主机:'WIN-EHSO6G1D9KD',ip:'192.168.13.2 ',os.name:'Windows Server 2012',os.arch:'amd64',os.version:'6.2', java.version:'1.8.0_91' 驱动程序信息:driver.version:FirefoxDriver at org .openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249) at org.openqa.selenium.remote.RemoteWebDriver。( RemoteWebDriver.java:131) 在org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:218) 在org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:211) 在org.openq (FirefoxDriver.java:207) at org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:120) at webdriverdemo.main(webdriverdemo.java:13) 引起: java.net.SocketException:连接重置 at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at org.apache.http.impl.io.SessionInputBufferImpl.streamRead( SessionInputBufferImpl.java:139) 在org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155) 在org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponsePa rser.java:140) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261) 在org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165) 在org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167) 在org.apache.http。 protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272) 在org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124) 在org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec。 java:271) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolEx (org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) 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:144) at org.openqa.selenium.remote.internal。 ApacheHttpClient.execute(ApacheHttpClient。的java:90) 在org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) 在org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160) 在有机openqa.selenium.firefox.FirefoxDriver $ LazyCommandExecutor.execute(FirefoxDriver.java:380) 在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 7个
Firefox版本47.0.6 平台Win2k12 r2
由于其工作却是露出什么异常。当我执行这段代码时,它打开两个chrome会话,一个chrome会话正常工作正常,但其他会话显示错误。我得到了下面的错误本次会议“关于端口启动ChromeDriver 2.22.397933(1cab651507b88dec79b2b2a22d1943c01833cc1b)18671个 只有本地连接被允许。(1cab651507b88dec79b2b2a22d1943c01833cc1b)端口37134个 只有本地连接被允许 开始ChromeDriver 2.22.397933。” –
现在我可以打开一个会话,并且工作正常,但会出现以下错误。你能帮我解决这个问题吗?在端口25061上启动ChromeDriver 2.22.397933(1cab651507b88dec79b2b2a22d1943c01833cc1b) 只允许本地连接。 –
尝试更新您的Chrome浏览器。我面临同样的问题。我将Chrome浏览器更新为最新的和使用最新的Chromedriver。它为我工作。我希望这也适用于你。 – BBP