alexschwantes / testcafe-browser-provider-selenium

This is the Selenium browser provider plugin for TestCafe. https://devexpress.github.io/testcafe/
MIT License
22 stars 20 forks source link

Timeout error when try to run test using GitLab Pipeline #37

Closed bharat-maher closed 7 months ago

bharat-maher commented 2 years ago

I created a testcafe runner file and running a test using selenium grid. Its working great from my machine but we need to do same operation using GitLab pipeline.

I am able to connect with selenium grid server but always getting Time-out error.

When I logged in to the selenium node server to check, I can see that testcafe open chrome browser instance but not able to start the test.

Here is my pipeline error:

Selenium server address is set to: http://myserver:4444/wd/hub
Error: Unable to open the "selenium:chrome" browser due to the following error:
WebDriverError: unknown error: net::ERR_CONNECTION_TIMED_OUT
  (Session info: chrome=102.0.5005.[63](https://gitlab.com/automation-test/load-testing/-/jobs/2556429847#L63))
    at Object.throwDecodedError (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/error.js:522:15)
    at parseHttpResponse (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/http.js:549:13)
    at Executor.execute (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/http.js:475:28)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)
    at Object.execute (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/webdriver.js:735:17)
    at BrowserConnection._runBrowser (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/testcafe/src/browser/connection/index.ts:214:32)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)

YAML File

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
  - node_modules/

stages:
   - deploy

e2e_tests:
    stage: deploy  
    tags:
       - shell-executor
    image: node:12.13.0-alpine
    before_script:
      - npm install
    script:
      - node testcafe_runner.js

Package.json

{
  "name": "TestCafe-TestRunner",
  "version": "0.0.0",
  "license": "MIT",
  "private": true,  
  "devDependencies": {
      "testcafe":"1.18.6",
      "testcafe-browser-provider-selenium":"1.2.0",
      "testcafe-reporter-html":"^1.4.4",
      "testcafe-reporter-xunit":"^2.1.0",
      "find-free-port":"2.0.0",
      "node-cmd":"^3.0.0",
      "internal-ip":"6.2.0",
      "fs-extra":"^6.0.1",
      "csv-parser":"^2.3.2",
      "csv-writer":"^1.6.0"
    }
}
alexschwantes commented 2 years ago

hi @bharat-maher, testcafe runs by proxying all pages in the browser via the testcafe server, so it needs direct network access between them. Have a read at https://devexpress.github.io/testcafe/documentation/how-it-works/

So it would seem that perhaps there is no connectivity between the servers in question. I'm not familiar with gitlab, but that would be my starting point to resolve the issue.

bharat-maher commented 2 years ago

There is connectivity between the servers. If I ping/telnet the IP in both side, its able to successfully receive all packages.

Selenium Grid is running on VPN network. I run my testcases while I am on VPN, I am still getting same error like GitLab ..

Chrome browser is open in selenium grid but its not able to start the test.. Chrome instance keep loading and time out error

alexschwantes commented 2 years ago

Your error message ERR_CONNECTION_TIMED_OUT indicates that it is likely a newtwork/firewall issue.

So Selenium server needs to be able to connect to the nodes, which it can do because it loads the chrome browser, but what it seem is the issue is that the node then can't connect to the server running testcafe. Are you able to manually telnet from the node to the testcafe server on the correct port?

Is your server 'myserver' defined as a hostname or an ip address? What version of selenium grid are you using? Where are you running the testcafe tests from, your localhost? If so, try without the firewall enabled.

Also, have a look at these other issues that might shed some light #12, #19

bharat-maher commented 2 years ago

Are you able to manually telnet from the node to the testcafe server on the correct port? -> I am able to manually telnet using IP but did not check with particular port. I will do this.

Is your server 'myserver' defined as a hostname or an IP address? -> Hostname

What version of selenium grid are you using? ->We tried with version 3 and 4th both.

Where are you running the testcafe tests from, your localhost? If so, try without the firewall enabled. -> I am running from localhost and GitLab both. I have runner file to first find the Internal-Ip and run test on free port using find-free-port library.

I will check those issues.

alexschwantes commented 7 months ago

Closing issue as it has been inactive for a long time.