SessionNotCreated Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure

Viewed 20

When i am running the selenium script from intellij the tests are running successfully.But its failing while the same script is running using docker image with error message Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure

I am Using Maven version :3.8.6 and java - 17.0.4 please help with this.

error:

Error message: SessionNotCreated Could not start a new session. Possible causes are  invalid address of the remote server or browser start-up failure.
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: '12b6393ad2b3', ip: '172.17.0.3', os.name: 'Linux', os.arch:  'amd64', os.version: '5.10.16.3-microsoft-standard-WSL2', java.version: '17.0.4.1'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: firefox,      platformName: LINUX}], desiredCapabilities=Capabilities {browserName: firefox, platformName: LINUX}}]
Capabilities {}
 [INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>untitled</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.22</version>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.3.0</version>
</dependency>
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.6.1</version>
    <scope>test</scope>
</dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>17</source>
                <target>17</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M7</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>
<properties>
    <java.version>17.0.4</java.version>
    <maven.compiler.source>17.0.4</maven.compiler.source>
    <maven.compiler.target>17.0.4</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

script:

public static WebDriver driver;
@Test
public void test() throws MalformedURLException
{
    String node = "http://localhost:4444/wd/hub";
    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setBrowserName("firefox");
    cap.setPlatform(Platform.LINUX);
    driver = new RemoteWebDriver(new URL(node), cap);
    cap.setCapability("marionette",true);
    driver.get("https://google.com");
    String t=driver.getTitle();
    System.out.println("title of the page : " + t);
}

dockerfile:

FROM eclipse-temurin:17-jdk-alpine
ARG MAVEN_VERSION=3.8.6
RUN apk add --no-cache curl tar bash procps
#copying src of the framework
COPY src /home/seleniumwithdocker/src
#copying pom.xml from framework
COPY pom.xml /home/seleniumwithdocker
#copying testng.xml from framework
COPY testng.xml /home/seleniumwithdocker
WORKDIR /home/seleniumwithdocker
ARG USER_HOME_DIR="/root"
ARG SHA=f790857f3b1f90ae8d16281f902c689e4f136ebe584aba45e4b1fa66c80cba826d3e0e52fdd04ed44b4c66f6d3fe3584a057c26dfcac544a60b301e6d0f91c26
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA}  /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
CMD mvn test
0 Answers
Related