Проблема с сессией Selenium + webdriverio

selenium
webdriver
Теги: #<Tag:0x00007f3d41038da8> #<Tag:0x00007f3d41038c68>

(Александр) #1

Есть xvfb и последний стабильный Chrome

Операционная система Debian

wdio.conf.js настройки

desiredCapabilities: {
    browserName: process.env.BROWSER || 'chrome',
    chromeOptions: {
      args: [
            '--no-sandbox',
          ],
      prefs: {
        'download.default_directory': __dirname + '/tmp/test/download',
        'download.prompt_for_download': false
      }
    }
  },

[10:17:21]  COMMAND	POST 	 "/wd/hub/session"
[10:17:21]  DATA		 {"desiredCapabilities":{"browserName":"chrome","version":"","javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"platform":"ANY","chromeOptions":{"args":["--no-sandbox"],"prefs":{"download.default_directory":"/app/tmp/test/download","download.prompt_for_download":false}},"loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"3.4.1","name":"webdriverio"}}}
Child Worker is ready 10022 id: 2
Master Worker is ready

Result of cron task "updating users online status" { online: 0, away: 0, offline: 0 }

[10:17:38]  SET SESSION ID 4f7668a9-a8db-4662-b1f9-5f86bc496e59
[10:17:38]  RESULT		 {"applicationCacheEnabled":false,"rotatable":false,"mobileEmulationEnabled":false,"networkConnectionEnabled":true,"chrome":{"chromedriverVersion":"2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5)","userDataDir":"/tmp/.org.chromium.Chromium.BtrXAQ"},"takesHeapSnapshot":true,"pageLoadStrategy":"normal","unhandledPromptBehavior":"","databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":true,"version":"58.0.3029.81","platform":"LINUX","browserConnectionEnabled":false,"nativeEvents":true,"acceptSslCerts":true,"webdriver.remote.sessionid":"4f7668a9-a8db-4662-b1f9-5f86bc496e59","locationContextEnabled":true,"webStorageEnabled":true,"browserName":"chrome","takesScreenshot":true,"javascriptEnabled":true,"cssSelectorsEnabled":true,"unexpectedAlertBehaviour":""}
[10:17:38]  COMMAND	POST 	 "/wd/hub/session/4f7668a9-a8db-4662-b1f9-5f86bc496e59/timeouts/async_script"
[10:17:38]  DATA		 {"ms":240000}
[10:17:38]  RESULT		 null
[10:17:38]  COMMAND	POST 	 "/wd/hub/session"
[10:17:38]  DATA		 {"desiredCapabilities":{"browserName":"chrome","version":"","javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"platform":"ANY","chromeOptions":{"args":["--no-sandbox"],"prefs":{"download.default_directory":"/app/tmp/test/download","download.prompt_for_download":false}},"loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"3.4.1","name":"webdriverio"}}}
[10:17:39]  SET SESSION ID 618305d0-22d2-44cc-bc70-6e7152a45efd
[10:17:39]  RESULT		 {"applicationCacheEnabled":false,"rotatable":false,"mobileEmulationEnabled":false,"networkConnectionEnabled":true,"chrome":{"chromedriverVersion":"2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5)","userDataDir":"/tmp/.org.chromium.Chromium.Yi7eOu"},"takesHeapSnapshot":true,"pageLoadStrategy":"normal","unhandledPromptBehavior":"","databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":true,"version":"58.0.3029.81","platform":"LINUX","browserConnectionEnabled":false,"nativeEvents":true,"acceptSslCerts":true,"webdriver.remote.sessionid":"618305d0-22d2-44cc-bc70-6e7152a45efd","locationContextEnabled":true,"webStorageEnabled":true,"browserName":"chrome","takesScreenshot":true,"javascriptEnabled":true,"cssSelectorsEnabled":true,"unexpectedAlertBehaviour":""}
[10:17:39]  COMMAND	POST 	 "/wd/hub/session/618305d0-22d2-44cc-bc70-6e7152a45efd/timeouts/async_script"
[10:17:39]  DATA		 {"ms":240000}
[10:17:39]  RESULT		 null

В чем может быть проблема?


(Александр) #2

desiredCapabilities: {
    browserName: process.env.BROWSER || 'chrome',
    chromeOptions: {
      args: [
            '--disable-gpu',
            '--headless',
            '--no-sandbox',
          ],
      prefs: {
        'download.default_directory': __dirname + '/tmp/test/download',
        'download.prompt_for_download': false
      }
    }
  },

Проблема решена этим, но...

Теперь другая проблема...

[07:07:40]  COMMAND	POST 	 "/wd/hub/session/21b26bbb-c9ee-4a4e-89de-ac6e8180fe9c/elements"
[07:07:40]  DATA		 {"using":"css selector","value":"form.register [placeholder='Access Code']"}
[07:07:40]  RESULT		 [{"ELEMENT":"34"}]
[07:07:40]  COMMAND	POST 	 "/wd/hub/session/21b26bbb-c9ee-4a4e-89de-ac6e8180fe9c/element/34/clear"
[07:07:40]  DATA		 {}
[07:07:40]  RESULT		 null
[07:07:40]  COMMAND	POST 	 "/wd/hub/session/21b26bbb-c9ee-4a4e-89de-ac6e8180fe9c/element/34/value"
[07:07:40]  DATA		 {"value":["s","i","m","u","l","a","t","i","o","n"]}
[07:07:41]  INFO	Retry #1
[07:07:41]  ERROR	ServerError	unknown error: an X display is required for keycode conversions, consider using Xvfb
[07:07:41]  INFO	Retry #2
[07:07:41]  ERROR	ServerError	unknown error: an X display is required for keycode conversions, consider using Xvfb
[07:07:41]  INFO	Gave up after 3 tries

(Сергей Кузьмин) #3

объявите
DISLAY см напр http://stackoverflow.com/questions/6183276/how-do-i-run-selenium-in-xvfb


(Александр) #4

          docker exec idg sh -c "Xvfb -ac :99 -screen 0 1280x1024x16 +extension RANDR > /dev/null 2>&1 &"
          docker exec idg sh -c "sleep 3"
          docker exec idg sh -c "export DISPLAY=:99"

Сделано, но не помогает...


(Сергей Кузьмин) #5

думаю что DISPLAY надо объявлять в том же exec в котором вызывается selenium