question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to connect to selenium chrome standalone container.

See original GitHub issue

What are you trying to achieve?

I am trying to follow the documentation regarding docker composer.

I use the following docker-compose.yml

version: '3'
services:
  codeceptjs:
    image: codeception/codeceptjs
    depends_on:
      - chrome
    volumes:
      - .:/tests
  chrome:
    image: selenium/standalone-chrome:3.8.1-bohrium
    ports:
      - '4444'
      - '5900'

and I run docker-compose up.

What do you get instead?

Recreating chrome_1 ... 
Recreating chrome_1 ... done
Recreating codeceptjs_1 ... 
Recreating codeceptjs_1 ... done
Attaching to chrome_1, codeceptjs_1
codeceptjs_1  | CodeceptJS directory has been found.
chrome_1      | 19:59:13.809 INFO - Selenium build info: version: '3.8.1', revision: '6e95a6684b'
chrome_1      | 19:59:13.814 INFO - Launching a standalone Selenium Server
chrome_1      | 2017-12-23 19:59:14.163:INFO::main: Logging initialized @1356ms to org.seleniumhq.jetty9.util.log.StdErrLog
chrome_1      | 19:59:14.327 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
chrome_1      | 19:59:14.372 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
chrome_1      | 19:59:14.383 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
chrome_1      | 19:59:14.386 INFO - Driver class not found: com.opera.core.systems.OperaDriver
chrome_1      | 19:59:14.386 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
chrome_1      | 19:59:14.392 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
chrome_1      | 19:59:14.395 INFO - Driver class not found: org.openqa.selenium.phantomjs.PhantomJSDriver
chrome_1      | 19:59:14.514 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
chrome_1      |  registration capabilities Capabilities {browserName: internet explorer, ensureCleanSession: true, platform: WINDOWS, version: } does not match the current platform LINUX
chrome_1      | 19:59:14.515 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
chrome_1      |  registration capabilities Capabilities {browserName: MicrosoftEdge, platform: WINDOWS, version: } does not match the current platform LINUX
chrome_1      | 19:59:14.516 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
chrome_1      |  registration capabilities Capabilities {browserName: safari, platform: MAC, version: } does not match the current platform LINUX
chrome_1      | 19:59:14.681 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
chrome_1      | 19:59:14.683 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
chrome_1      | 19:59:14.683 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
chrome_1      | 19:59:14.686 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
chrome_1      | 19:59:14.686 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
chrome_1      | 19:59:14.711 INFO - Using the passthrough mode handler
chrome_1      | 2017-12-23 19:59:14.880:INFO:osjs.Server:main: jetty-9.4.7.v20170914
chrome_1      | 2017-12-23 19:59:14.983:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@7cbd213e{/,null,STARTING} has uncovered http methods for path: /
chrome_1      | 2017-12-23 19:59:14.998:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@7cbd213e{/,null,AVAILABLE}
chrome_1      | 2017-12-23 19:59:15.087:INFO:osjs.AbstractConnector:main: Started ServerConnector@509f3a27{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
chrome_1      | 2017-12-23 19:59:15.089:INFO:osjs.Server:main: Started @2282ms
chrome_1      | 19:59:15.089 INFO - Selenium Server is up and running
codeceptjs_1  | CodeceptJS v1.1.1
codeceptjs_1  | Using test root "/tests"
codeceptjs_1  | 
codeceptjs_1  | Creation of investor's account. Some Validations --
 ✖ "before all" hook: codeceptjs.beforeSuite in 37ms
codeceptjs_1  | Error: connect ECONNREFUSED 127.0.0.1:4444
codeceptjs_1  | Creation of investor's account --
 ✖ "before all" hook: codeceptjs.beforeSuite in 10ms
codeceptjs_1  | Error: connect ECONNREFUSED 127.0.0.1:4444
codeceptjs_1  | 
codeceptjs_1  | -- FAILURES:
codeceptjs_1  | 
codeceptjs_1  |   1) Creation of investor's account. Some Validations
codeceptjs_1  |        "before all" hook: codeceptjs.beforeSuite:
codeceptjs_1  |      connect ECONNREFUSED 127.0.0.1:4444
codeceptjs_1  |   
codeceptjs_1  |   Run with --verbose flag to see NodeJS stacktrace
codeceptjs_1  | 
codeceptjs_1  |   2) Creation of investor's account
codeceptjs_1  |        "before all" hook: codeceptjs.beforeSuite:
codeceptjs_1  |      connect ECONNREFUSED 127.0.0.1:4444
codeceptjs_1  |   
codeceptjs_1  |   Run with --verbose flag to see NodeJS stacktrace
codeceptjs_1  | 
codeceptjs_1  | 
codeceptjs_1  |   FAIL  | 0 passed, 2 failed   // 77ms
codeceptjs_1 exited with code 1

Details

  • Operating System: MAC OSX
  • WebDriverIO
  • Configuration file:
  "tests": "./*_test.js",
  "timeout": 50000,
  "output": "./output",
  "helpers": {
     "WebDriverIO" : {
       "smartWait": 5000,
       "browser": "chrome",
       "desiredCapabilities": {
         "chromeOptions": {
           "args": [ "--incognito"]
         }
       },
       "url":"https://www.as.com",
       "restart": false,
       "windowSize": "maximize",
       "timeouts": {
         "script": 60000,
         "page load": 10000
       }
     }
   },
  "include": {
    "I": "./steps_file.js",
    "SignupPage":"./pages/signup.page.js",
    "Onboarding":"./pages/onboarding.page.js",
    "Dashboard":"./pages/dashboard.page.js",
    "Financials":"./pages/financials.page.js"
  },
  "bootstrap": false,
  "mocha": {
    "reporterOptions": {
        "mochaFile": "output/result.xml"
    }
  },
  "name": "exercise"
}

My first thought was that it tries to connect to the selenium server before it is ready, I added a command to the compose with wget with retries and after 4 mins it is still not able to connect.

I am not sure if it is a bug, but I haven’t been able to execute the tests and I ran out of ideas.

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
slawertcommented, Dec 24, 2017

nevermind : the host that i had to use was:

"host":"chrome"

and everything worked as expected. Thanks @DavertMik for the hints.

0reactions
aoyamaYcommented, Mar 13, 2019

I meet this issue, too! See my terminal log:

DEPRECATION WARNING WebDriverIO helper is deprecated
DEPRECATION WARNING WebDriverIO was based on webdriverio package v4 which is outdated now
DEPRECATION WARNING Upgrade to "webdriverio@5" and switch to WebDriver helper
CodeceptJS v2.0.7
Using test root "/home/developer/gavin/sc-e2e-test"
Helpers: WebDriverIO, Login, Register, Locator, ShadowDom, MysqlDBManage, TxClient, TxWeb, VirtualMachine, Message, Benchmark, SequelizeDBManage, ConnectSequelize, ConnectDB, ConfigSchema, SystemMsgSchema, DeviceSchema, ClientExceptionSchema, InvitationSchema, InvoicesSchema, InvoiceStatesSchema, InvoiceInfosSchema, NetInfoSchema, OrderItemsSchema, OrderQuantitiesSchema, OrderStatesSchema, OrdersSchema, OrgsSchema, PaymentsSchema, PreAccountsSchema, ProductLimitModesSchema, ProductLimitsSchema, ProductsSchema, SummariesSchema, TerminalSchema, TrialCardsSchema, UsersSchema, CloudtrustActiveSchema, AccountSchema, CloudtrustAccountSchema, Ln2Locator, Ln2MysqlDBManage, registerTimeSchema, blockSiteExceptionSchema, ToolCommendSchema, ToolSchema, ToolUsageRecordSchema, SequelizeMongoDBManage, TxApi
Plugins: screenshotOnFail, allure

dashboard --
 › [Session] Starting singleton browser session
  ✖ "before all" hook: codeceptjs.beforeSuite in 1569ms
(node:10535) UnhandledPromiseRejectionWarning: Error: socket hang up
(node:10535) 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:10535) [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.
  ✖ "after all" hook: codeceptjs.afterSuite in 1ms
(node:10535) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(node:10535) UnhandledPromiseRejectionWarning: Error: socket hang up
(node:10535) 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: 2)

-- FAILURES:

  1) dashboard
       "before all" hook: codeceptjs.beforeSuite:
     Can't connect to WebDriver.
Error: socket hang up

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible
  Error: socket hang up
  
  Run with --verbose flag to see NodeJS stacktrace
  
  Run with --verbose flag to see NodeJS stacktrace

  2) dashboard
       "after all" hook: codeceptjs.afterSuite:
     Can't connect to WebDriver.
Error: socket hang up

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible
  Error: socket hang up
  
  Run with --verbose flag to see NodeJS stacktrace
  
  Run with --verbose flag to see NodeJS stacktrace


  FAIL  | 0 passed, 2 failed   // 2s
(node:10535) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2)
(node:10535) UnhandledPromiseRejectionWarning: Error: socket hang up

Run with --verbose flag to see NodeJS stacktrace

Run with --verbose flag to see NodeJS stacktrace
(node:10535) 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: 3)

😢 But when i restart my computer, the issue just disappear and everything is ok again! I think maybe my computer’s cpu or memory or something is not enough. See my top log:

top - 15:27:32 up 1 day,  4:17,  1 user,  load average: 0.90, 0.91, 1.02
Tasks: 309 total,   1 running, 293 sleeping,  15 stopped,   0 zombie
%Cpu(s): 11.5 us,  3.4 sy,  0.0 ni, 76.8 id,  8.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 16291756 total,   860768 free,  9124004 used,  6306984 buff/cache
KiB Swap: 16635900 total, 16136940 free,   498960 used.  5185672 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                 
11250 develop+  20   0  832892 192816  88700 S  11.6  1.2   1:14.93 chrome                                                                                                                                  
 2987 develop+  20   0 1746692 281484  52928 S   6.3  1.7  54:58.80 compiz                                                                                                                                  
 1063 root      20   0  825124 257192 212632 S   4.6  1.6  51:31.48 Xorg                                                                                                                                    
 7105 develop+  20   0  858332 212916 105848 S   2.6  1.3   0:35.85 chrome                                                                                                                                  
 5063 develop+  20   0  712384  38592  22888 S   2.0  0.2   0:52.01 gnome-terminal-                                                                                                                         
 6810 develop+  20   0 1633644 322168 133924 S   1.7  2.0  53:50.57 chrome                                                                                                                                  
 6852 develop+  20   0  848528 351328 271076 S   1.3  2.2 156:33.78 chrome                                                                                                                                  
 3248 develop+  20   0 1474772  69348  44868 S   0.7  0.4   1:14.91 nautilus                                                                                                                                
 9506 develop+  20   0 1606276 226536 110436 S   0.7  1.4   0:08.00 atom                                                                                                                                    
  896 root      20   0    4396    768    700 S   0.3  0.0   0:47.81 acpid                                                                                                                                   
 1052 root      20   0  611624   7788   6332 S   0.3  0.0   9:31.23 ECAgent                                                                                                                                 
 1704 develop+  20   0   44636   4720   2740 S   0.3  0.0   1:10.40 dbus-daemon                                                                                                                             
 1779 root      20   0  633972  62036  37352 S   0.3  0.4   2:34.77 dockerd                                                                                                                                 
 1874 root      20   0  530952  39132  20948 S   0.3  0.2   2:43.71 docker-containe                                                                                                                         
 2954 develop+   9 -11  576516  10880   8580 S   0.3  0.1   1:42.72 pulseaudio                                                                                                                              
 2961 develop+  20   0  972732   8720   7760 S   0.3  0.1   0:30.58 indicator-datet                                                                                                                         
 3267 develop+  20   0  803688  83488  27704 S   0.3  0.5   1:19.20 docky                                                                                                                                   
 9554 develop+  20   0 1402012 245584 117732 S   0.3  1.5   0:11.82 atom                                                                                                                                    
12161 root      20   0       0      0      0 S   0.3  0.0   0:00.07 kworker/u4:0                                                                                                                            
14150 develop+  20   0  504708  62364  38360 S   0.3  0.4   1:54.98 Discord                                                                                                                                 
25594 develop+  20   0 3913888 2.227g 2.174g S   0.3 14.3  20:15.96 VirtualBox                                                                                                                              
    1 root      20   0  185856   6088   3700 S   0.0  0.0   0:25.68 systemd                                                                                                                                 
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd                                                                                                                                
    3 root      20   0       0      0      0 S   0.0  0.0   0:08.96 ksoftirqd/0                                                                                                                             
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                                                                                                            
    7 root      20   0       0      0      0 S   0.0  0.0   0:54.78 rcu_sched                                                                                                                               
    8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh                                                                                                                                  
    9 root      rt   0       0      0      0 S   0.0  0.0   0:00.17 migration/0                                                                                                                             
   10 root      rt   0       0      0      0 S   0.0  0.0   0:00.18 watchdog/0                                                                                                                              
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.20 watchdog/1                                                                                                                              
   12 root      rt   0       0      0      0 S   0.0  0.0   0:00.16 migration/1                                                                                                                             
   13 root      20   0       0      0      0 S   0.0  0.0   0:09.62 ksoftirqd/1                                                                                                                             
   15 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:0H                                                                                                                            
   16 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kdevtmpfs                                                                                                                               
   17 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 netns                                                                                                                                   
   18 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 perf                                                                                                                                    
   19 root      20   0       0      0      0 S   0.0  0.0   0:00.10 khungtaskd                                                                                                                              
   20 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 writeback                                                                                                                               
   21 root      25   5       0      0      0 S   0.0  0.0   0:00.00 ksmd                                                                                                                                    
   22 root      39  19       0      0      0 S   0.0  0.0   0:00.70 khugepaged                                                                                                                              
   23 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 crypto                                                                                                                                  
   24 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kintegrityd                                                                                                                             
   25 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 bioset                                                                                                                                  
   26 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kblockd                                                                                                                                 
   27 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 ata_sff                                                                                                                                 
   28 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 md                                                                                                                                      
   29 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 devfreq_wq                                                                                                                              
   34 root      20   0       0      0      0 S   0.0  0.0   0:14.06 kswapd0                                                                                                                                 
   35 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 vmstat                                                                                                                                  
   36 root      20   0       0      0      0 S   0.0  0.0   0:00.00 fsnotify_mark                                                                                                                           
   37 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ecryptfs-kthrea                                                                                                                         
   53 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kthrotld                                                                                                                                
   54 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 acpi_thermal_pm                                                                                                                         

🙊 And this is my command to build the webdriver container:

docker run -d -p 4444:4444 -p 5900:5900 --dns 192.168.0.6 -e SCREEN_HEIGHT=1080 -e SCREEN_WIDTH=1920 selenium/standalone-chrome-debug:3.7.0-arsenic
Read more comments on GitHub >

github_iconTop Results From Across the Web

can't connect to selenium/standalone-chrome docker ...
Using hostname setting in the docker compose file, I can proper connect and run the automated tests with success.
Read more >
Docker Container stuck at Started Selenium Standalone 4.4.0 ...
I'm trying to use Selenium inside a Docker container but after running the docker container the console stays stuck at.
Read more >
Selenium with Chrome in Docker - Reddit
I try to connect to the Chrome container from my code (outside of a container, using http://127.0.0.1:4444) and get this error: (The process ......
Read more >
Testing a website with Selenium and Docker - LogRocket Blog
Use Selenium and Docker to test a website, and start a Selenium Grid that allows you to test a website on Chrome and...
Read more >
selenium/standalone-chrome-debug - Docker Image
Wasm is a fast, light alternative to Linux containers – try it out today with the Docker+Wasm Beta. ✕.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found