Giter Club home page Giter Club logo

testcafe-browser-provider-selenium's Introduction

testcafe-browser-provider-selenium

Build Status

This is the Selenium browser provider plugin for TestCafe.

Install

npm install testcafe-browser-provider-selenium

Prerequisites

A Selenium Server up and running, either as standalone or in a grid. Check out the Selenium's Docker images for an easy way to get started with setting up a grid.

Usage

If you run tests from the command line, use the browser alias when specifying browsers. The '-c 2' parameter will split the tests up and run them across two browsers concurrently. Omit this if it is not needed.

testcafe -c 2 selenium:chrome 'path/to/test/file.js'

When you use API, pass the alias to the browsers() method:

testCafe
    .createRunner()
    .src('path/to/test/file.js')
    .browsers('selenium:chrome')
    .concurrency(2)
    .run();

Supported browsers

The following browser name alias' are supported

  • chrome
  • firefox
  • safari
  • ie
  • edge

Specifying the Browser Version and Platform

The browser version and platform can be specified along with the browser name alias in the format:

selenium:browserName[@version][:platform]

for example:

Customize Capabilities

Tests can be run as above without any need for additional customisation. However a configuration file (default is capabilities.json) can be used to pass custom args to a browser or to run a test using Chrome's mobile device emulation.

The format for the first level object is browserAlias[#profile][@version][:platform].

for example:

{
    "chrome@83": {
        "goog:chromeOptions": {
            "args": [
                "headless",
                "--use-fake-ui-for-media-stream",
                "--use-fake-device-for-media-stream",
                "--allow-http-screen-capture",
                "--disable-web-security"
            ]
        }
    },
    "chrome#iphoneX": {
        "goog:chromeOptions": {
            "mobileEmulation": {
                "deviceName": "iPhone X"
            }
        }
    },
    "chrome#customMobile": {
        "goog:chromeOptions": {
            "mobileEmulation": {
                "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",
                "deviceMetrics": {
                    "width": 360,
                    "height": 640,
                    "pixelRatio": 3.0
                }
            }
        }
    }
}

The configuration for chrome#iphonex uses Chrome's built in presets for the device by setting the deviceName to "iPhone X". The list of presets is likely to change so check Google Chrome DevTools for what is currently available.

You can always set a custom user agent and device metrics as shown in chrome#customMobile.

Running the Test

Run tests on any availble Firefox browser

testcafe selenium:firefox test.js

Run tests on any available Firefox browser on Windows

testcafe selenium:firefox:windows test.js

Run tests on Chrome version 83 with custom args defined in capabilities.json. (Note that capabilities.json is not required for this command to work, if it has not been defined the tests will attempte to run on Chrome version 83 in the selenium grid with default Chrome args)

testcafe selenium:chrome@83 test.js

Run tests with Chrome iPhone X emulation as configured in capabilities.json

testcafe selenium:chrome#iphonex test.js

Run tests with custom Chrome emulation as configured in capabilities.json

testcafe selenium:chrome#customMobile test.js

Enable Video Recording

Follow the testcafe instructions, by adding @ffmpeg-installer/ffmpeg to you project dependencies.

Run the test using testcafe's standard video options eg.

testcafe selenium:chrome tests/test.js --video reports/screen-captures

Configuration

Use the following optional environment variable to set additional configuration options:

  • SELENIUM_SERVER - (optional) The url to the selenium server. If not set the default 'http://localhost:4444/wd/hub' will be used.
  • SELENIUM_HEARTBEAT - (optional) Adjust or disable the selenium heartbeat. Default is 10,000 milliseconds, set to <= 0 to disable.
  • SELENIUM_CAPABILITIES - (optional) Path to capabilities file. Default is capabilities.json.
  • SELENIUM_MAX_TRIES - (optional) Max tries of opening browser. Default is 1.
  • SELENIUM_RETRY_INTERVAL - (optional) Interval between retries of opening browser. Default is 5,000 milliseconds.
  • SELENIUM_PROXY - (optional) Sets the URL of the proxy to use for the WebDriver's HTTP connections.

Author

Alex Schwantes

testcafe-browser-provider-selenium's People

Contributors

alexschwantes avatar jefftherobot avatar link89 avatar oemekaogala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

testcafe-browser-provider-selenium's Issues

Can i pass user agent to use android chrome with this package

With local chrome browser, we have capability to use user agent like this:
testcafe "chrome --user-agent='Mozilla/5.0\ \(Linux\;\ Android\ 5.0\;\ SM-G900P\ Build/LRX21T\)\ AppleWebKit/537.36\ \(KHTML,\ like\ Gecko\)\ Chrome/57.0.2987.133\ Mobile\ Safari/537.36'" test.js

This gives me, logs like

Running tests in:
 - Chrome 57.0.2987.133 / Android 5.0

Can i replicate this with your package:
I tried:
testcafe selenium:"chrome --user-agent='Mozilla/5.0\ \(Linux\;\ Android\ 5.0\;\ SM-G900P\ Build/LRX21T\)\ AppleWebKit/537.36\ \(KHTML,\ like\ Gecko\)\ Chrome/57.0.2987.133\ Mobile\ Safari/537.36'" test.js

But , it's not working.
PS: i have selenium hub and chrome node up and running.

Video recording not working in chrome docker

Suppose i am on mac and want to test my testcafe scripts on linux chrome.
Approach i have followed is to use chrome docker image along with package - testcafe-browser-provider-selenium
It all works fine, but now i need to record video and i am getting error:
Video recording is not supported by the "selenium:chrome" browser.

What is your Test Scenario?
Run testcafe on chrome docker image and record video successfully.

What is the Current behavior?
getting error:
Video recording is not supported by the "selenium:chrome" browser.

What is the Expected behavior?
Video should be recorded

What is your web application and your TestCafe test code?
Precondition: this package should be installed:
npm install testcafe-browser-provider-selenium
Test code (my_first_test.js)

fixture `Getting Started`
    .page `http://google.com`;

    test('Sample test', async t => {
        await t
        console.log("webpage opened")
    })

DockerFile:

FROM node:latest AS node_base

RUN npm install --save @ffmpeg-installer/ffmpeg

FROM selenium/standalone-chrome

USER root

COPY --from=node_base . .

RUN echo "file ends..."

Setup container(dockerfile in same folder)

docker build -t mychrome:1.6 .
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm mychrome:1.6

run testcafe:
testcafe selenium:chrome my_first_test.js

Everything works well till now, so lets try to record video:
testcafe selenium:chrome my_first_test.js --video myvideo

This is the result:

Using locally installed version of TestCafe.
 Running tests in:
 - Chrome 81.0.4044.92 / Linux 0.0

 Getting Started
webpage opened
 ✓ Sample test


 1 passed (2s)

 Warnings (1):
 --
  Video recording is not supported by the "selenium:chrome" browser.

I want to have video support. Please check if this is possible.

Note from testcafe support:
The selenium browser provider plug-in you mentioned should have this support implemented via the getVideoFrameData method.

Package not working for android devices

I am trying to run testcafe tests on android chrome.

This is my docker-compose.yml

version: "3"
services:
 hub:
   image: selenium/hub
   container_name: hub
   ports:
     - "4444:4444"
 samsung_galaxy:
   image: butomo1989/docker-android-x86-8.1
   privileged: true
   links:
     - hub
   depends_on:
     - hub
   ports:
     - "6080:6080"
   environment:
     - DEVICE=Samsung Galaxy S6
     - CONNECT_TO_GRID=True
     - APPIUM=true
     - SELENIUM_HOST=hub
     - MOBILE_WEB_TEST=False
     - AUTO_RECORD=True

After doing docker-compose up, i can see device in http://0.0.0.0:4444/grid/console
Screenshot 2020-06-03 at 10 04 27 PM

Now when i try to run my tests, i get error:

[my_first_project (master)]$ testcafe selenium:chrome:android my_first_test.js 
Using locally installed version of TestCafe.
The "src", "browsers" options from the configuration file will be ignored.
ERROR Was unable to open the browser "selenium:chrome:android" due to error.

WebDriverError: Error forwarding the new session cannot find : Capabilities {browserName: chrome, platformName: android}
    at Object.checkLegacyResponse (/Users/xxx/node_modules/selenium-webdriver/lib/error.js:585:15)
    at parseHttpResponse (/Users/xxx/node_modules/selenium-webdriver/lib/http.js:556:13)
    at Executor.execute (/Users/xxx/node_modules/selenium-webdriver/lib/http.js:491:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Type "testcafe -h" for help.

WebDriverError: java.net.ConnectException: Connection refused

Hi,
I'm not able to connect one of selenium remote grid through testcafe-browser-provider-selenium plugin and getting browser open on remote host , however getting empty white screen (it says keep on loading the browser in remote host) , I'm not sure this is due to proxy issue or other capabilities that i need to disable in capabilities.json during the run .. Can you please let me know what is right capabilities.json file data to resolve the

Here’s my run command :
SELENIUM_SERVER=http://{my_remote_grid_host:portNumber}/wd/hub testcafe selenium:chrome tests/exampleTest.js

Here’s error getting during test run :
ERROR Was unable to open the browser "selenium:chrome" due to error.

WebDriverError: java.net.ConnectException: Connection refused (Connection refused)
at Object.checkLegacyResponse (/node_modules/selenium-webdriver/lib/error.js:585:15)
at parseHttpResponse (/node_modules/selenium-webdriver/lib/http.js:556:13)
at Executor.execute (/node_modules/selenium-webdriver/lib/http.js:491:26)
at process._tickCallback (internal/process/next_tick.js:68:7)

If i want to try the SELENIUM_CAPABILITIES="capabilities.json" , it also doesn't work , what is correct JSON data for chrome and firefox browser ,I tried following the default one ,it doesn't work

{
"chrome@73": {
"chromeOptions": {
"args": [
"headless",
"--use-fake-ui-for-media-stream",
"--use-fake-device-for-media-stream",
"--allow-http-screen-capture",
"--disable-web-security"
]
}
}
}

cannot connect to selenium chrome container

Hello Alex,
I'm having trouble connecting to the chrome container using the 0.3.0 version of testcafe-browser-provider-selenium. I supplied some repo steps below. Please let me know if you need more details.
Thanks.

  1. docker-compose.yml

version: '2'
services:
chrome:
image: selenium/node-chrome:3.141.59-gold
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub

hub:
image: selenium/hub:3.141.59-gold
ports:
- "4444:4444"

  1. docker-compose up

  2. Connection code:
    createTestCafe('localhost', 1338 + iteration, 1339 + iteration)
    .then(function(tc) {
    cafeRunner = tc
    const runner = tc.createRunner()
    return runner
    .src('./test.js')
    .screenshots('./reports/screenshots', true)
    .browsers('selenium:chrome')
    .run()
    .catch(function(error) {
    console.error(error)
    })
    })
    .then(function(report) {})

  3. Error Messages: chrome container logs:
    2019-02-11 19:34:57,817 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
    2019-02-11 19:34:57,819 INFO supervisord started with pid 7
    2019-02-11 19:34:58,821 INFO spawned: 'xvfb' with pid 10
    2019-02-11 19:34:58,822 INFO spawned: 'selenium-node' with pid 11
    Connecting to the Hub using the host hub and port 4444
    2019-02-11 19:34:58,865 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
    2019-02-11 19:34:58,865 INFO success: selenium-node entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
    19:34:59.064 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
    19:34:59.151 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 5555
    2019-02-11 19:34:59.216:INFO::main: Logging initialized @346ms to org.seleniumhq.jetty9.util.log.StdErrLog
    19:34:59.379 INFO [WebDriverServlet.] - Initialising WebDriverServlet
    19:34:59.440 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 5555
    19:34:59.440 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Selenium Grid node is up and ready to register to the hub
    19:34:59.496 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
    19:34:59.777 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://hub:4444/grid/register
    19:34:59.830 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
    19:36:28.681 INFO [ActiveSessionFactory.apply] - Capabilities are: {
    "browserName": "chrome",
    "goog:chromeOptions": {
    }
    }
    19:36:28.684 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
    Starting ChromeDriver 2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926) on port 17775
    Only local connections are allowed.
    Please protect ports used by ChromeDriver and related test framew[or1k5s4 9t9o1 3p7r8e8v.e7n1t1 ]a[cScEeVERE]: bind() failed: Csannot assign requested address (99)
    s by malicious code.
    19:36:29.177 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
    19:36:29.495 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 530de56c5b29e5db48517cc96b438a96 (org.openqa.selenium.chrome.ChromeDriverService)

  4. TestCafe Error message:
    Server started on port 3000
    { Error: Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.
    at BrowserSet._callee4$ (c:\costar-suite-market-search\tests\node_modules\testcafe\lib\runner\browser-set.js:219:44)
    at tryCatch (c:\costar-suite-market-search\tests\node_modules\regenerator-runtime\runtime.js:62:40)
    at Generator.invoke [as _invoke] (c:\costar-suite-market-search\tests\node_modules\regenerator-runtime\runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (c:\costar-suite-market-search\tests\node_modules\regenerator-runtime\runtime.js:114:21)
    at step (c:\costar-suite-market-search\tests\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
    at c:\costar-suite-market-search\tests\node_modules\babel-runtime\helpers\asyncToGenerator.js:35:14
    at new Promise ()
    at new F (c:\costar-suite-market-search\tests\node_modules\core-js\library\modules_export.js:36:28)
    at BrowserSet. (c:\costar-suite-market-search\tests\node_modules\babel-runtime\helpers\asyncToGenerator.js:14:12)
    at BrowserSet._waitConnectionsOpened (c:\costar-suite-market-search\tests\node_modules\testcafe\lib\runner\browser-set.js:237:26)
    at c:\costar-suite-market-search\tests\node_modules\testcafe\lib\runner\browser-set.js:263:31
    at invokeCallback (c:\costar-suite-market-search\tests\node_modules\pinkie\index.js:60:12)
    at Array.forEach ()
    at publish (c:\costar-suite-market-search\tests\node_modules\pinkie\index.js:147:32)
    at Array.publishFulfillment (c:\costar-suite-market-search\tests\node_modules\pinkie\index.js:152:2)
    at Immediate.asyncFlush [as _onImmediate] (c:\costar-suite-market-search\tests\node_modules\pinkie\index.js:17:19) constructor: [Function: GeneralError] }

testcafe server must be accessible from selenium-node?

I am trying to run testcafe tests on selenium grid and in our CI setup, selenium-node is not able to access testcafe server (running on a CI agent), due to network limitations. Selenium-node can only access selenium-hub. Is there a way to get it working in this setup?

Thanks.

New version coming??

Hi, it is been +2 years since last release, is it coming any new version or features? thank you in advance

How to specify/pass browser version?

Hi Alex. Is there a way we pass/specify the browser version for e.g selenium:chrome:66 or selenium:edge:16 ? Can you provide us this option? Thanks.

Unable to pass browser CLI argument as environment variable (parsing error)

Whenever I attempt to specify the browser CLI argument as an environment variable, the string is parsed incorrectly.

Using the following command to invoke tests unexpectedly fails:

export SELENIUM_SERVER=http://foo.bar:4444/wd/hub
export SELENIUM_BROWSER=selenium:chrome
npx testcafe ${SELENIUM_BROWSER}

The error thrown indicates the string is parsed incorrectly, with items shifted so that the selenium substring is passed for the browserName field and the browser name is passed for browserVersion:

The "browsers", "filter" options from the configuration file will be ignored.
ERROR Was unable to open the browser "selenium:chrome" due to error.

WebDriverError: Error forwarding the new session cannot find : Capabilities {browserName: selenium, browserVersion: chrome}
    at Object.checkLegacyResponse (/Users/Mike/Development/foo/node_modules/selenium-webdriver/lib/error.js:585:15)
    at parseHttpResponse (/Users/Mike/Development/foo/node_modules/selenium-webdriver/lib/http.js:556:13)
    at Executor.execute (/Users/Mike/Development/foo/node_modules/selenium-webdriver/lib/http.js:491:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Type "testcafe -h" for help.

If I forgo using an environment variable to define the browser then this works as expected.

Proxy with testcafe-browser-provider-selenium

Is it possible to use testcafe-browser-provider-selenium with a proxy option (perhaps with selenium capabilities json).
In fact, to acces a grid launched in AWS I have to use a proxy.

Running multiple testcafe runs over a grid mess things up

Hi
This is probably not an issue with your package but maybe you can help me out by finding out how to fix it.
I have a grid with 50 nodes connected to it.
When I run testcafe with 50 concurrencies it runs fine, but if I try to run another testcafe job at the same time, things start to mess up.
Is this an expected behavior?
I've set 3 sessions for each node, doesn't it means that a node can handle 3 request from 3 different jobs?

Incorrect tests behaviour when run concurrently on chrome grid

We are having an issue when running tests with concurrency (occurs even with -c 2) on chrome selenium grid ( not occurs on firefox). Tests reporter does not output any results and the tests get stuck until you manually open and focus the browser- then the browsers are eventually closed and build finishes. All the details and reproduction steps are present here: DevExpress/testcafe#7164 as i have initially thought that this is testcafe issue, hence created it for testcafe.

Multi Window Error while running test cases

Getting this error while running a test using 'selenium: chrome'

Multi window mode is supported in Chrome, Chromium, Edge 84+ and Firefox only. Run tests in these browsers to use the "openWindow" method

I tried with the latest version of Testcafe and testcafe-browser-provider-selenium

Testcafe plugin not working with Selenium Grid implementation in K8s

All the details are here in #19 but because it is closed, opening a new one with more details and rc2 of Selenium Grid v4

Selenium grid now provides a env variable called SE_NODE_GRID_URL which can be passed to grid nodes so CDP internal ip url can be replaced with hub url. - see SeleniumHQ/selenium#9202 for reference.
But even with this, when I run testcafe (plugin) against selenium grid v4, I see the browser is trying a url like this in the attached image

image

Because this env variable is set, I can see this in the node config so I expect testcafe cdp url will be using this but it still uses a private IP as shown in the screenshot. btw, it is HTTPS as well.

[node]
grid-url = "https://test322.us-west-2.dev.test.com"
session-timeout = "180"
override-max-sessions = false
detect-drivers = false
max-sessions = 1

and grid cdp url also looks like this "se:cdp": "wss://test322.us-west-2.dev.test.com/session/44d984661045fd76d8b0da6570fd0886/se/cdp",

Run the testcafe on hosted selenium grid

Hi Alex,

Thanks for the package. When I run selenium grid, it works.
However, we have selenium grid host on AWS, when I try to run the test with the hosted selenium, I can see that the tests are running. I cannot see the logs of the running test.

Do you have any good practice for this?

Thanks,
Daming

Timeout error when try to run test using GitLab Pipeline

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"
    }
}

Selenium Grid v4-alpha-6 with https not working with this plugin

I am running selenium grid v4-alpha-6 running on K8s with traefik. Here my hub url will be like https://test.hub.xyz.org.com/wd/hub with HTTPS protocol.

This is how I am running the test:
`
export NODE_TLS_REJECT_UNAUTHORIZED=0
npm config set strict-ssl false

export SELENIUM_SERVER="https://test.hub.xyz.org.com/wd/hub"
testcafe "selenium:chrome" scripts/scripts.js
`
This is the exception I get every time I run a test against TestCafe using this plugin.

18:21:49 updated 1 package in 2.402s
18:22:58 ERROR Was unable to open the browser "selenium:chrome" due to error.
18:22:58 
18:22:58 ScriptTimeoutError: NettyHttpHandler request execution error
18:22:58     at Object.throwDecodedError (/data/jenkins/.nvm/versions/node/v9.4.0/lib/node_modules/testcafe-browser-provider-selenium/node_modules/selenium-webdriver/lib/error.js:550:15)
18:22:58     at parseHttpResponse (/data/jenkins/.nvm/versions/node/v9.4.0/lib/node_modules/testcafe-browser-provider-selenium/node_modules/selenium-webdriver/lib/http.js:565:13)
18:22:58     at Executor.execute (/data/jenkins/.nvm/versions/node/v9.4.0/lib/node_modules/testcafe-browser-provider-selenium/node_modules/selenium-webdriver/lib/http.js:491:26)
18:22:58     at <anonymous>
18:22:58     at process._tickCallback (internal/process/next_tick.js:160:7)
18:22:58 
18:22:58 Type "testcafe -h" for help.

Full printed log
https://gist.github.com/ambirag/7a3558cfd646fb2eb217d7eb4080d047

Here the IP and in other exceptions is the IP of the Node Pod where browser Chrome was running.

cdp: 'http://10.2.xx.xxxx:5555/session/0437b82665405bade94f2fe0931d0d3f/se/cdp

Hub is running fine:ttps://test.hub.xyz.org.com/wd/hub/status

I can see the session details under /wd/hub/status once test start to run but test fails with error shown above.

{
  "value": {
    "ready": true,
    "message": "Selenium Grid ready.",
    "nodes": [
      {
        "id": "b8f08baa-0e04-4326-a9d3-xxxx",
        "uri": "http:\u002f\u002f10.x.x.x:5555",
        "maxSessions": 1,
        "stereotypes": [
          {
            "capabilities": {
              "browserName": "chrome"
            },
            "count": 1
          }
        ],
        "sessions": [
        ]
      }
    ]
  }
}


I tried with capabilities.json like this as well

{
    "chrome": {
        "goog:chromeOptions": {
            "w3c": true/false,
            "args": [
                "--ignore-certificate-errors",
                "--no-sandbox",
                "--no-proxy-server",
                "--test-type",
                "--disable-web-security",
                "--allow-insecure-localhost",
                "--disable-gpu"
            ]
        }
    }
}

This plugin does work if I run Selenium v4 grid locally like this with HTTP

docker network create grid
$ docker run -d -p 4444:4444 --net grid --name selenium-hub selenium/hub:4.0.0-alpha-6-20200730
$ docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-chrome:4.0.0-alpha-6-20200730
$ docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-firefox:4.0.0-alpha-6-20200730
export SELENIUM_SERVER=http://localhost:4444/wd/hub
testcafe -c 4 "selenium:chrome" scripts/scripts.js

But my hub runs on k8s with treafik, and we use https, can you help why this is not working?

Tests against a remote Selenium Grid time out because Testcafé seems to try making the Grid browser reach the host it runs on

Hi,

I've created a gist with the very simple "litmus" test setup I'm using to verify the problem at https://gist.github.com/manuelkiessling/81a61c42df3edfa3bd2af60bdbed81fd.

I'm only using Testcafé 1.0.1 and testcafe-browser-provider-selenium 0.3.0, and run my test case against a Selenium Grid.

This works well if the Selenium Grid runs on the same host where I launch the test run.

It fails as soon as the Selenium Grid runs on another, remote host, with the following error:

WebDriverError: Reached error page: about:neterror?e=netTimeout&u=http%3A//10.104.8.148%3A58160/browser/connect/0CERNlP&c=UTF-8&f=regular&d=The%20server%20at%2010.104.8.148%20is%20taking%20too%20long%20to%20respond.
    at Object.throwDecodedError (/Users/manuelkiessling/git/selenium-grid/simple-tests/testcafe/node_modules/selenium-webdriver/lib/error.js:550:15)
    at parseHttpResponse (/Users/manuelkiessling/git/selenium-grid/simple-tests/testcafe/node_modules/selenium-webdriver/lib/http.js:542:13)
    at Executor.execute (/Users/manuelkiessling/git/selenium-grid/simple-tests/testcafe/node_modules/selenium-webdriver/lib/http.js:468:26)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)

My impression is that Testcafé wants to make the remote browser running in the Grid connect to http://10.104.8.148:58160/browser/connect/0CERNlP, which it can't reach, because 10.104.8.148 is the local IP of the desktop system I'm using to launch the Testcafé run, and which cannot be reached from the Selenium Grid host.

The phenomenon does not occur when running a Selenium test case written in Python (see https://gist.github.com/manuelkiessling/81a61c42df3edfa3bd2af60bdbed81fd#file-simpletest-py) - it works reliably with a local Selenium Grid and with a remote Selenium Grid.

How is the plugin running with testcafe behind the hood?

Hi @alexschwantes,

I am new to testcafe and this plugin, and currently I could use testcafe and this plugin to communicate with selenium grid and run test cases concurrently, it's a wonderful tool!

But I'd like to know what happened when "testcafe -c 2 selenium:chrome 'path/to/test/file.js'" is executed behind the hood? I know that testcafe also has the abililty to start the browser. So the browser in remote grid node is started by testcafe? or selenium webdriver?
Could you please give me a guide or a brief introduction of the call stack of how this plugin work with testcafe? Thanks very much!

webdriver error

Hi @alexschwantes,
I encountered a small err, and I would need your help.
I have this package installed,

"dependencies": {
"testcafe-browser-provider-selenium": "^0.4.0",
"yargs": "^12.0.2"
}

and I'm calling the execution of the tests, from this npm script:

"scripts": {
"test:desktop": "set SELENIUM_SERVER=http://selenoid.ads:4444/wd/hub && testcafe selenium:chrome src/tests/*.e2e.ts
}

the call of the npm script is:

npm run test:desktop

and the I'm getting this weird error:
Untitled

Do you have any idea what other dependency do I need?
10X

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.