Я запускаю приложение Protractor Sample, и оно не работает в контейнере.Я пробовал то же приложение на физической машине, и оно работает, как и ожидалось, и проходит тестовый пример.
Мой тестовый код: -> CheckTitleSpec.js
//CheckTitleSpec.js2
describe('Protractor Demo', function() {
it('to check the page title', function() {
browser.ignoreSynchronization = true;
browser.get('https://www.softwaretestinghelp.com/');
browser.driver.getTitle().then(function(pageTitle) {
expect(pageTitle).toEqual('Software Testing Help - Free Software Testing & IT Tutorials and Courses');
});
});
});
Файл conf.js
// conf.js
exports.config = {
framework: 'jasmine',
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ["--headless", "--disable-gpu", "--window-size=800x600"]
}
},
specs: ['CheckTitleSpec.js']
};
Файл Docker для построения контейнера:
FROM node:latest
USER root
RUN apt-get update && apt-get -y upgrade
RUN apt-get -y install software-properties-common
RUN apt-get install default-jre -y
RUN npm install -g protractor
RUN webdriver-manager update
RUN npm install protractor-jasmine2-screenshot-reporter
# Install Chrome
RUN wget https://dl.google.com/linux/direct/google-chrome- stable_current_amd64.deb
RUN apt install ./google-chrome-stable_current_amd64.deb -y
COPY CheckTitleSpec.js /
COPY conf.js /
ENTRYPOINT [ "sh", "-c", "protractor /conf.js" ]
На контейнере вывод:
java -version
java version "1.8.0_212"
Java(TM) SE Runtime Environment (build 1.8.0_212-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.212-b12, mixed mode)
webdriver-manager version
I/version - webdriver-manager 12.1.4
node -v
v11.12.0
npm -v
6.7.0
protractor --version
Version 5.4.2
google-chrome --version
Google Chrome 74.0.3729.131
protractor conf.js
[10:32:53] I/launcher - Running 1 instances of WebDriver
[10:32:53] I/local - Starting selenium standalone server...
[10:32:55] I/local - Selenium standalone server started at http://172.17.0.2:49496/wd/hub
[10:32:56] E/launcher - unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch- heads/3729@{#29}),platform=Linux 4.9.125-linuxkit x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 147 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '153e772db9cd', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.125-linuxkit', java.version: '1.8.0_212'
Driver info: driver.version: unknown
[10:32:56] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch- heads/3729@{#29}),platform=Linux 4.9.125-linuxkit x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 147 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '153e772db9cd', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.125-linuxkit', java.version: '1.8.0_212'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (/usr/local/lib/node_modules /protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/usr/local/lib/node_modules/protractor /node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/usr/local/lib/node_modules/protractor /node_modules/selenium-webdriver/lib/http.js:441:30)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
From: Task: WebDriver.createSession()
at Function.createSession (/usr/local/lib/node_modules /protractor/n ode_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:761:15)
at createDriver (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:626:16)
at Local.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:195:43)
at q.then.then (/usr/local/lib/node_modules/protractor/built/runner.js:339:29)
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules /protractor/node_modules/q/q.js:796:13)
[10:32:56] E/launcher - Process exited with error code 199
Я тестировал тот же код на физическом Linuxкоробка без головы, и она работает, как ожидалось.
Любая ведет с благодарностью.
Спасибо.