0

I just started to learn Selenium WebDriver. Could you all help me to resolve below problem. I simply want to open the web-site(I am able to open browser successfully but navigation got failed )

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();
    }
}

I found below errors :

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58' System info: host: '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 info: 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) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:218) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:211) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:207) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120) at webdriverdemo.main(webdriverdemo.java:13) Caused by: java.net.SocketException: Connection reset 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) at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155) at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261) at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165) at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167) at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272) at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) at 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) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160) at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:380) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)

... 7 more

Firefox version 47.0.6 Platform Win2k12 r2

Edi G.
  • 2,432
  • 7
  • 24
  • 33
Vishal Negi
  • 1
  • 1
  • 3

2 Answers2

0

Seems like there is some issue with creating session with Firefox. Try the following code and test using Chrome browser.

You need to download the executable driver from: https://sites.google.com/a/chromium.org/chromedriver/downloads

public static void main(String[] args){
    System.setProperty("webdriver.chrome.driver","/path/to/chromedriver");
    WebDriver driver = new ChromeDriver();
    driver = new ChromeDriver();
    //Puts an Implicit wait, Will wait for 10 seconds before throwing exception
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    //Launch website
    driver.get("http://www.calculator.net/");

    //Maximize the browser
    driver.manage().window().maximize();
}
BBP
  • 46
  • 8
  • Thanks its working but it is showing something abnormal. When i executed this code and it is opening the two chrome session, one session of chrome is working fine as expected but other session showing error. I got below errors this session "Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b) on port 18671 Only local connections are allowed. Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b) on port 37134 Only local connections are allowed." – Vishal Negi Jul 12 '16 at 05:34
  • Now i am able to open the one session and it is working fine, but below errors are coming. Could you help me to resolve this? Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b) on port 25061 Only local connections are allowed. – Vishal Negi Jul 12 '16 at 05:47
  • Try updating your Chrome browser. I faced the same issue. I updated the Chrome browser to latest and used latest Chromedriver. It worked for me. I hope this works for you as well. – BBP Jul 13 '16 at 10:04
  • Thanks for the input.. New problem occur while using Firefox http://stackoverflow.com/questions/38393395/error-exception-in-thread-main-org-openqa-selenium-remote-unreachablebrowsere " – Vishal Negi Jul 15 '16 at 10:12
0
ChromeOptions ops = new ChromeOptions();
ops.addArguments("--remote-allow-origins=*");
WebDriver driver = new ChromeDriver(ops);
driver.get("https://www.flipkart.com/");

use this code, it will work

Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24