0
votes

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.

1

1 Answers

0
votes

Its might be because of chrome driver and browser version please check the versions and use the correct versions.