5

I am using Testcafe (free version) with Java Script. I want to run all my test cases (resides in multiple test scripts in __test__ directory) in a single browser instance (That way 1 time log in) per browser type.

  1. For example, 1 instance for chrome and 1 instance for safari but all tests will run before closing the browser.
  2. If a test fails, I want the screenshot is taken and count number of the test failures. But do want to continue.
  3. I'm doing all on Node 12 Docker image, so it is best if I don't need to install anything else.

How do I do this with Testcafe?

const createTestCafe = require('testcafe') let testcafe = null let runner = null createTestCafe('localhost', 1337, 1338) .then(tc => { testcafe = tc const runner = testcafe.createRunner() return runner .src([ '__test__/*.js' ]) .browsers([ 'chrome:headless --no-sandbox --disable-gpu', 'safari' ]) .screenshots('./reports/screenshots/', true) .run({ selectorTimeout: 10000, assertionTimeout: 10000, }) }) runner .screenshots({ path: 'reports/screenshots/', takeOnFails: true, }) .then(failedCount => { console.log('Tests failed: ' + failedCount) testcafe.close() }) .catch(error => { console.log("An ERROR detected:" + error) }) 

This is how you install chrome on Dockerfile. Can someone tell me how to install Firefox on Dockerfile?

RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \ http_proxy=${http_proxy} https_proxy=${https_proxy} apt-get update && \ http_proxy=${http_proxy} https_proxy=${https_proxy} apt-get install -y --allow-unauthenticated google-chrome-stable && \ apt clean && rm -rf /var/lib/apt/lists/* 

2 Answers 2

4

It's impossible to meet all requirements at once.

1) For example, 1 instance for chrome and 1 instance for safari but all tests will run before closing the browser.

You cannot install the Chrome and Safari web browsers on docker image. It's possible to install only Chromium and Firefox on it. See the Using TestCafe docker help topic for more information.

2) If a test fail, I want the screen shot taken and count number of test failed. But do want to continue.

TestCafe's Live mode works in the same way, but it's not available on docker.

Sign up to request clarification or add additional context in comments.

2 Comments

I have chrome installed on Docker.
I think there is a shortage of available resources using docker for this requirement.
2
+25

This case you need to use Session Handling

During test execution, the Selenium WebDriver has to interact with the browser all the time to execute given commands. At the time of execution, it is also possible that, before current execution completes, someone else starts execution of another script, in the same machine and in the same type of browser.

more details

1 Comment

My question is about Testcafe, NOT Selenium.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.