简体   繁体   中英

Getting chrome is not reachable error while running selenium test cases in gitlab-ci.It seems some issue with headless chrome can anyone help on this

I am facing issue while integrating my selenium java based test cases with gitlab-ci with docker compose

This is my gitlab_ci.yml file- image: maven:3.5-jdk-8

variables: selenium_remote_url: " http://selenium__standalone-chrome:4444/wd/hub/ " GIT_SSL_NO_VERIFY: "true" stages: - build building: stage: build services: - selenium/standalone-chrome:latest script: - mvn clean - mvn install tags: - dind-build

And this is docker compose file-

version: '2' services: firefox: image: selenium/node-firefox:3.14.0-gallium volumes: - /dev/shm:/dev/shm depends_on: - hub environment: HUB_HOST: hub

chrome: image: selenium/node-chrome:3.14.0-gallium volumes: - /dev/shm:/dev/shm depends_on: - hub environment: HUB_HOST: hub

hub: image: selenium/hub:3.14.0-gallium ports: - "4444:4444"

This is my code for baseclass public class BaseClass {

public static WebDriver driver;
public static Properties prop;
private static final String URL_Selenium_Hub = "http://selenium_standalone-chrome:4444/wd/hub";
public BaseClass(){

    try {
        prop = new Properties();
        FileInputStream in = new FileInputStream(System.getProperty("user.dir")+ "/src/main/java/com/udds/config/configfile");
        prop.load(in);
    }

    catch(FileNotFoundException e){
        e.printStackTrace();
    }

    catch(IOException e){
        e.printStackTrace();
    }
}

public static void initializeWebdriver() throws MalformedURLException{

    DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--headless");
        options.addArguments("--disable-gpu");
        options.addArguments("--no-sandbox");


        driver = new RemoteWebDriver(new URL(URL_Selenium_Hub), chromeCapabilities);
        driver.manage().window().maximize();

        driver.get("url");


    }
}

This error i am getting in gitlab ci:

[ERROR] Tests run: 15, Failures: 5, Errors: 0, Skipped: 10, Time elapsed: 0.964 s <<< FAILURE! - in TestSuite [ERROR] SetUp(com.udds.TestCases.DataTransformationTest) Time elapsed: 0.755 s <<< FAILURE! 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.

它可能是因为Chrome驱动程序和浏览器版本请检查版本并使用正确的版本。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM