Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chromeOptions not accepting window-size argument #13

Closed
kkrishan opened this issue Apr 8, 2018 · 4 comments
Closed

chromeOptions not accepting window-size argument #13

kkrishan opened this issue Apr 8, 2018 · 4 comments

Comments

@kkrishan
Copy link

kkrishan commented Apr 8, 2018

dockerfile:

FROM node:9-alpine

RUN echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
    && apk add --no-cache \
    python \
    build-base \
    git \
    bash \
    openjdk8-jre-base \
    # chromium dependencies
    nss@edge \
    chromium-chromedriver@edge \
    chromium@edge 
   USER node

  ENV CHROME_BIN /usr/bin/chromium-browser
  ENV CHROME_PATH /usr/lib/chromium/

Protractor.conf.js :

chromeDriver: '/usr/bin/chromedriver',
directConnect: true,

capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
       args: ['no-sandbox','headless','window-size=1366,768'],

Error

UnhandledPromiseRejectionWarning: WebDriverError: no such session

Tried
1.In jenkinsfile :

    agent {
        
       	dockerfile {
		label "din"
		args "-v /tmp:/tmp --name Builder --net host --privileged -v /dev/shm:/dev/shm -e SCREEN_WIDTH=1366 -e SCREEN_HEIGHT=768"
		}
	
    }
  1. Tried In protractor.conf.js :
'window-size=1366,768'
'window-size=1366x768'
'--window-size=1366x768'
'screen-size=1366x768'
  1. tried updating protractor to protractor@5.3.1 (was at 5.1) and using
'goog:chroomeOptions' : {
   args: ['no-sandbox','headless','window-size=1366,768'],
}

Detailed Error :

> protractor  protractor.conf.js

[20:23:30] D/launcher - Running with --troubleshoot
[20:23:30] D/launcher - Protractor version: 5.1.2
[20:23:30] D/launcher - Your base url for tests is undefined
(node:104) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[20:23:30] I/launcher - Running 1 instances of WebDriver
[20:23:30] I/direct - Using ChromeDriver directly...
[20:23:30] D/runner - WebDriver session successfully started with capabilities Capabilities {
  'acceptSslCerts' => true,
  'applicationCacheEnabled' => false,
  'browserConnectionEnabled' => false,
  'browserName' => 'chrome',
  'chrome' => { chromedriverVersion: '2.33 (6b5fa7bf9d0fa9821c8666484)',
  userDataDir: '/tmp/.org.chromium.Chromium.kodpec' },
  'cssSelectorsEnabled' => true,
  'databaseEnabled' => false,
  'handlesAlerts' => true,
  'hasTouchScreen' => false,
  'javascriptEnabled' => true,
  'locationContextEnabled' => true,
  'mobileEmulationEnabled' => false,
  'nativeEvents' => true,
  'networkConnectionEnabled' => false,
  'pageLoadStrategy' => 'normal',
  'platform' => 'Linux',
  'rotatable' => false,
  'setWindowRect' => true,
  'takesHeapSnapshot' => true,
  'takesScreenshot' => true,
  'unexpectedAlertBehaviour' => '',
  'version' => '64.0.3282.168',
  'webStorageEnabled' => true }
[20:23:30] D/runner - Running with spec files /jenkins/workspace/test_dev-YR7ZQV3UNW7VJ4GXEBWMEBAA/Modules/features/test.feature
******************************************************************************************
>>>>>>>>>>> Feature  :Test <<<<<<<
>>>>>>>>>>> Scenario : test1<<<<<<
*******************************************************************************************

(node:104) UnhandledPromiseRejectionWarning: WebDriverError: no such session
  (Driver info: chromedriver=2.33 (6b5fa7bf9d0fa982e74b7c8666484),platform=Linux 3.10.0-693.5.2.el7.x86_64 x86_64)
    at Object.checkLegacyResponse (/jenkins/workspace/test-bot_dev-YR7ZQV3UNW7JSL4PEPEGXEBWMEBAA/node_modules/selenium-webdriver/lib/error.js:505:15)
    at parseHttpResponse (/jenkins/workspace/test-bot_dev-YR7ZSL4PEPEGXEBWMEBAA/node_modules/selenium-webdriver/lib/http.js:509:13)
    at doSend.then.response (/jenkins/workspace/test-bot_dev-YR7ZQV3UNW7BWMEBAA/node_modules/selenium-webdriver/lib/http.js:440:13)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)
(node:104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Stackoverflow :

Stackoverflow..

@sylvaindumont
Copy link
Owner

I can't reproduce it, my protractor tests have no problem with 'window-size=1366,768'

You can try adding 'disable-gpu', it's recommended with headless for now.
You can try with the debian version of the image, the alpine version is by far the most capricious.
You can try the xvfb variant too, this variant allows you to run chrome without headless flag.

goog:chroomeOptions seems to have typo. goog:chromeOptions should work better.

@kkrishan
Copy link
Author

kkrishan commented Apr 8, 2018

Thanks for quick confirmation.

Tried adding 'disable-gpu' . No success.

Tried debian version , got exactly same behaviour as alpine.

Everything runs fine when 'window-size=1366,768' argument is removed but that runs in default window size 800,600 it seems , so test cases fail due to overlapping of components.
Tried increasing window size using but failed with same error:

   onPrepare: function () {
        browser.driver.manage().window().setSize(1366,768); 
        or
     browser.driver.manage().window().setSize(new Dimension(1366, 768));

Can it be a privilage or chrome user issue ? Though i tried using --privileged while running docker as shown in jenkinsfile above.

@sylvaindumont
Copy link
Owner

try adding --shm-size=1gb to your docker config in jenkins instead of --privileged -v /dev/shm:/dev/shm

@kkrishan
Copy link
Author

kkrishan commented Apr 9, 2018

--shm-size=1gb solved the issue .

Thank you !! .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants