Saurabh Shrivastava
Saurabh Shrivastava

Reputation: 1484

How to run testcafe from local on chrome docker image

I don't want to install chrome to run testcafe and want to use a chrome docker image. Step1:

docker run -d -p 4444:4444 selenium/standalone-chrome

Step2:

docker container ls
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                    NAMES
3487d6a08310        selenium/standalone-chrome   "/opt/bin/entry_poin…"   About an hour ago   Up About an hour    0.0.0.0:4444->4444/tcp   charming_proskuriakova

Step3: This code works for python2.7

from selenium import webdriver

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

driver=webdriver.Remote(
          command_executor='http://0.0.0.0:4444/wd/hub',
          desired_capabilities=DesiredCapabilities.CHROME)


driver.get("https://www.google.com/")  
print driver.title
driver.close() 

I am looking to use same functionality for testcafe. Base code(test1.js):

    import { Selector } from 'testcafe';

    fixture `Getting Started`
        .page `http://devexpress.github.io/testcafe/example`;

    test('My first test', async t => {
        // Test code
});

Execution on local Chrome:

testcafe chrome test1.js

I am looking for method to replace chrome with docker image. I know, chrome is inbuilt with testcafe, you can consider "safari" or any other browser in place of chrome. IDea is learn to use docker image in testcafe. PS: I dont want to use testcafe/testcafe image since my issue is not running testcafe in docker , but only browser in docker.

Upvotes: 0

Views: 1159

Answers (1)

Shurygin.Sergey
Shurygin.Sergey

Reputation: 431

Could you please clarify why don't you want to use the testcafe docker image?  It seems that selenium/standalone-chrome image also contains selenium related code which listen api requests and runs test on a browser installed inside the container.

Note: testcafe doesn't have built-in browsers, it runs locally installed browsers.

An alternate way to run a browser inside a docker image is to use the remote browser functionality (https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html#remote-browsers). You will need to run tescafe with a 'remote' browser alias  and then run a browser inside a container via the 'docker run' command and pass it the 'http:///browser/connect' link

Upvotes: 1

Related Questions