gpt4 book ai didi

java - Selenium 远程独立服务器 - 驱动程序未知

转载 作者:行者123 更新时间:2023-12-01 17:34:24 25 4
gpt4 key购买 nike

我在 Google Cloud Platform Run with Firefox、Gecko 和 Selenium Standalone Server Jar 文件版本 4.0.0-alpha-1 中有一个 docker 容器。有了这个我就有了这个图像:

FROM ubuntu:bionic
LABEL maintainer="Matheus Carvalho Gomes Moreira, matheus@hrestart.com.br"
EXPOSE 4444
ENV PORT 4444
ENV VERSION "V6.1"

# Systems update
RUN apt-get update && apt-get install -y \
python3 python3-pip \
fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \
libnspr4 libnss3 lsb-release xdg-utils libxss1 libdbus-glib-1-2 \
curl unzip wget \
xvfb

# install java and selenium-server-standalone

RUN apt-get install openjdk-8-jdk -y
RUN wget -O /home/selenium-standalone.jar http://selenium-release.storage.googleapis.com/4.0/selenium-server-standalone-4.0.0-alpha-1.jar

# setup Java Environment

RUN export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
RUN export PATH=$PATH:$JAVA_HOME/bin

# install geckodriver and firefox

RUN GECKODRIVER_VERSION=`curl https://github.com/mozilla/geckodriver/releases/latest | grep -Po 'v[0-9]+.[0-9]+.[0-9]+'` && \
wget https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz && \
tar -zxf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/local/bin && \
chmod +x /usr/local/bin/geckodriver && \
rm geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz

RUN FIREFOX_SETUP=firefox-setup.tar.bz2 && \
apt-get purge firefox && \
wget -O $FIREFOX_SETUP "https://download.mozilla.org/?product=firefox-latest&os=linux64" && \
tar xjf $FIREFOX_SETUP -C /opt/ && \
ln -s /opt/firefox/firefox /usr/bin/firefox && \
rm $FIREFOX_SETUP

CMD tail -f /dev/null
CMD DISPLAY=:1 xvfb-run java -jar /home/selenium-standalone.jar

还有我的客户:

FirefoxOptions options = new FirefoxOptions();
driver = new RemoteWebDriver(new URL("${URL_TO_CONTAINER}"), options);

但是当我尝试创建访问端点的远程驱动程序的实例时,它会给出以下错误:

Unable to create new service: GeckoDriverService
Build info: version: '4.0.0-alpha-1', revision: 'd1d3728cae', time: '2019-04-24T16:15:24'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0', java.version: '1.8.0_242'
Driver info: driver.version: unknown

我搜索了一下,可能是因为找不到安装的 Firefox 和 Gecko 来初始化服务。大家有什么想法吗?

最佳答案

我没有使用过 geckodrivers,但我发现了这个 project ,您可以将其用作测试,然后在代码中弄清楚如何设置驱动程序和下一个 article了解如何在 docker 容器中使用 selenium 设置应用程序。

关于java - Selenium 远程独立服务器 - 驱动程序未知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61066575/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com