Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

docker - 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()

}

});

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...