Versionen:
- Java 21
- Selenium 4.25.0
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean package
FROM openjdk:21-jdk-slim
# Install necessary packages and dependencies
RUN apt-get update && \
apt-get install -y wget unzip curl gnupg2 && \
apt-get install -y \
libxss1 \
libappindicator3-1 \
libgconf-2-4 \
libgtk-3-0 \
libx11-xcb1 \
libxcomposite1 \
libxcursor1 \
libxi6 \
libxtst6 \
libnss3 && \
# Install Chromium from a known source for ARM architecture
echo "deb http://deb.debian.org/debian bullseye main" >> /etc/apt/sources.list && \
apt-get update && \
apt-get install -y chromium && \
apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/script-selenium-1.0-SNAPSHOT.jar /app/selenium-example.jar
# Set the working directory
WORKDIR /app
# Specify the command to run the application
CMD ["java", "-jar", "selenium-example.jar"]
und hier ist meine Hauptmethode:
final Selenium selenium = new Selenium(true); selenium.getDriver().get("https://www.google.com"); System.out.println("Browser opened");
public Selenium(final boolean isHeadless) {
if (isHeadless) {
options.addArguments("--headless=new", "--no-sandbox", "--disable-dev-shm-usage");
}
this.driver = new ChromeDriver(options);
}
Ich erhalte diese Ausnahme:
Ausnahme im Thread „main“ org.openqa.selenium.SessionNotCreatedException: Könnte keine neue Sitzung starten. Mögliche Ursachen sind eine ungültige Adresse des Remote-Servers oder ein Browser-Startfehler.
2024-10-10 22:13:53 Host-Info: Host: 'dee756ebfb70', IP: '172.22.0.3'
Ich möchte ein Headless-Browsing ausführen, das zu google.com führt. Was ist das Problem?