See the stackrace:
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
...
... TestNG 6.14.3 by C?dric Beust (cedric@beust.com)
...
Local Operating System: LINUX
Local Architecture: amd64
Selected Browser: FIREFOX
Disable AI based Visual Testing: true
Headless Mode: true
Connecting to Selenium Grid: false
Local Operating System: LINUX
Local Architecture: amd64
Selected Browser: FIREFOX
Disable AI based Visual Testing: true
Headless Mode: true
Connecting to Selenium Grid: false
Unable to capture screenshot: null
Local Operating System: LINUX
Local Architecture: amd64
Selected Browser: FIREFOX
Disable AI based Visual Testing: true
Headless Mode: true
Connecting to Selenium Grid: false
Unable to clear cookies: null
Test Execution Time: 0 minutes, 0 seconds
java.lang.NullPointerException
at com.netsol.configs.AutomationFactory.closeEyes(AutomationFactory.java:151)
at com.netsol.base.SeleniumBase.closeAutomationObjects(SeleniumBase.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:458)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:425)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.615 s <<< FAILURE! - in TestSuite
[ERROR] searchSomethingInGoogle(com.package.tests.features.frontend.TEST_GoogleSearch) Time elapsed: 0.108 s <<< FAILURE!
java.lang.IllegalStateException: The driver executable does not exist: /home/automation/myproject
at com.package.tests.features.frontend.TEST_GoogleSearch.searchSomethingInGoogle(TEST_GoogleSearch.java:25)
[ERROR] closeAutomationObjects(com.package.tests.features.frontend.TEST_Demo) Time elapsed: 0.175 s <<< FAILURE!
java.lang.NullPointerException
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] TEST_Demo>SeleniumBase.closeAutomationObjects:101 ? NullPointer
[ERROR] TEST_GoogleSearch.searchSomethingInGoogle:25->SeleniumBase.getDriver:62 ? IllegalState
[INFO]
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.142 s
[INFO] Finished at: 2019-05-29T09:21:51Z
Мне нужно выполнить свои тесты Selenium в контейнерах Docker. Я знаю, что Selenium предоставляет контейнеры-концентраторы и узлы, но мне нужно написать свой собственный Dockerfile, который будет создавать контейнер, который будет выполнять тесты без конфигурации сетки. В принципе, я не могу использовать сетку по некоторым причинам. Я написал Dockerfile. Это передается на этапе сборки. Однако, когда я запускаю контейнер, он не создает экземпляр браузера и выдает исключение, что java.lang.IllegalStateException: исполняемый файл драйвера не существует: / home / Automation / MyProject
Кроме того, обратите внимание, что мне нужно выполнить свои тесты в режиме без головы, чтобы в моем проекте уже была конфигурация для запуска браузера в режиме без головы.
Я попытался предоставить + rwx разрешения для того, куда я загружаю и разархивирую свои файлы.
Смотрите мой Dockerfile ниже:
FROM ubuntu:latest
LABEL name="myproject" \
author="TAFSEER HAIDER" \
version="1.0" \
description="Execute backend and frontend tests using myproject in containers"
# Install Essential Softwares
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& apt-get -y install openjdk-8-jdk \
&& apt-get install -y maven \
&& apt-get install -y firefox \
&& apt-get install -y unzip \
&& apt-get install -y curl \
&& apt-get install -y xvfb \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/ /tmp/* /var/tmp/*
# Chrome browser to run the tests
ARG CHROME_VERSION=latest
RUN if [ ${CHROME_VERSION} = "latest" ]; then curl https://dl-ssl.google.com/linux/linux_signing_key.pub -o /tmp/google.pub && cat /tmp/google.pub | apt-key add -; rm /tmp/google.pub && echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' > /etc/apt/sources.list.d/google.list && mkdir -p /usr/share/desktop-directories && apt-get -y update && apt-get install -y google-chrome-stable; else curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add && wget https://www.slimjet.com/chrome/download-chrome.php?file=lnx%2Fchrome64_$CHROME_VERSION.deb && dpkg -i download-chrome*.deb || true && apt-get install -y -f && rm -rf /var/lib/apt/lists/*;fi
# Disable the SUID sandbox so that chrome can launch without being in a privileged container
RUN dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome \
&& echo "#!/bin/bash\nexec /opt/google/chrome/google-chrome.real --no-sandbox --disable-setuid-sandbox \"\$@\"" > /opt/google/chrome/google-chrome \
&& chmod 755 /opt/google/chrome/google-chrome
RUN if [ ${CHROME_DRIVER_VERSION} != "latest" ]; then mkdir -p /opt/selenium && curl http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -o /opt/selenium/chromedriver_linux64.zip && cd /opt/selenium; unzip /opt/selenium/chromedriver_linux64.zip; rm -rf chromedriver_linux64.zip; ln -fs /opt/selenium/chromedriver /usr/local/bin/chromedriver;fi
#Firefox browser to run the tests
ARG FIREFOX_VERSION=latest
RUN FIREFOX_DOWNLOAD_URL=$(if [ $FIREFOX_VERSION = "latest" ]; then echo "https://download.mozilla.org/?product=firefox-$FIREFOX_VERSION-ssl&os=linux64&lang=en-US"; else echo "https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2"; fi) \
&& apt-get update -qqy \
&& apt-get -qqy --no-install-recommends install firefox \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
&& wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL \
&& apt-get -y purge firefox \
&& rm -rf /opt/firefox \
&& tar -C /opt -xjf /tmp/firefox.tar.bz2 \
&& rm /tmp/firefox.tar.bz2 \
&& mv /opt/firefox /opt/firefox-$FIREFOX_VERSION \
&& ln -fs /opt/firefox-$FIREFOX_VERSION/firefox /usr/bin/firefox
# Add a user for running applications.
RUN apt-get update && apt-get install sudo -y \
&& adduser --disabled-password --gecos '' automation \
&& adduser automation sudo \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/ /tmp/* /var/tmp/*
# Copy myprojectproject to the specified directory in containerized Ubuntu Linux
COPY --chown=automation . /home/automation/myproject/
# Set working directory
WORKDIR /home/automation/myproject/
RUN chown -R automation:automation /home/automation/myproject\
&& chmod -R 777 /home/automation/myproject\
&& chmod -R +rwx /home/automation/myproject
USER automation
# Clean & compile myproject
RUN mvn clean test-compile