Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webdriver exception: "chrome not reachable"

I am running selenium test cases in a ubuntu server which basically runs testcases in both firefox and chrome. Firefox launches and test cases run successfully but chrome throws exception:

*****below is the snippet of the stacktrace:*****

Starting ChromeDriver (v2.8.240825) on port 21549

PAC support disabled because there is no system implementation

Test IntegrationTest.AdminUserelementscheck failed:

org.openqa.selenium.WebDriverException: chrome not reachable (Driver info: chromedriver=2.8.240825,platform=Linux 2.6.32-431.el6.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information) [error] Command duration or timeout: 20.83 seconds


Hi Below is the small snippet of my code :

public class IntegrationTest {

private static final String configFile="test.properties";

private final String FIREFOX="firefox";

private final String CHROME="chrome";

private final String PHANTOMJS="phantomjs";

private final String BROWSERNAME="browser";

private static Properties props = new Properties();

public WebDriver webDriver;

private static Configuration additionalConfigurations;


@BeforeClass

public static void setUp() throws IOException, SQLException{

props.load(IntegrationTest.class.getResourceAsStream("/" + configFile));
        }

@test

public void AdminUserelementscheck() throws SQLException, IOException {

String[] browsers = props.getProperty(BROWSERNAME).split(",");

System.out.println("Number of browsers specified in conf:"+props.getProperty(BROWSERNAME));

for(String browser:browsers){

System.out.println("Browser currently processing:"+browser);

if(browser.equalsIgnoreCase(FIREFOX))

webDriver = new FirefoxDriver();

else if(browser.equalsIgnoreCase(CHROME))

webDriver = new ChromeDriver();

else

webDriver = new PhantomJSDriver();

running(testServer(3333,fakeApplication()),webDriver, new Callback<TestBrowser>() {


********* LOGIN AND ASSERTION STATMENTS*******************

browser.quit()

}

});

}
like image 279
Immanuel Fredrick Avatar asked Feb 06 '15 10:02

Immanuel Fredrick


People also ask

How do I disable Chrome Webdriver?

We can stop a page loading with Selenium webdriver in Chrome browser by using the JavaScript Executor. Selenium can execute JavaScript commands with the help of the executeScript command. To stop a page loading, the command window. stop() is passed as a parameter to the executeScript method.

How do I fix ChromeDriver executable in path?

To solve the Selenium error "WebDriverException: Message: 'chromedriver' executable needs to be in PATH", install and import the webdriver-manager module by running pip install webdriver-manager . The module simplifies management of binary drivers for different browsers.

Where should I put the chrome driver in Selenium?

Now we need to move ChromeDriver somewhere that Python and Selenium will be able to find it (a.k.a. in your PATH ). The easiest place to put it is in C:\Windows . So move it there!


3 Answers

This would be because Chrome is also making use of unix containers in order to run. If you want this to run within docker, pass the docker run command

--privileged

Otherwise you can start Chrome with

--no-sandbox

like image 83
Conor Avatar answered Oct 04 '22 20:10

Conor


I have encoutered similar problem. I am running my Selenium tests locally and "webdriver exception chrome not reachable" error suddenly showed up.

The problem was that I already had too much tabs in my regular chrome browser. After getting frustrated I have closed few tabs and suddenly it worked. I am not sure if there is a certain limit of tabs, but if somebody encounters same problem, give it a try.

like image 41
sKyTzi Avatar answered Oct 04 '22 19:10

sKyTzi


Your chrome driver seems to be old. Try downloading latest as of date from below and report back if you get any new errors.

http://chromedriver.storage.googleapis.com/index.html?path=2.14/

like image 37
nilesh Avatar answered Oct 04 '22 20:10

nilesh