1

I am trying to execute the Karate script in mcr.microsoft.com/playwright:bionic Docker container.

I have exposed the port 5900 as shown below but not sure how to get the playwrightUrl for the container. Do I need to execute the node server.js inside it to get websocket endpoint?

docker run --name playwright -it --rm --ipc=host --cap-add=SYS_ADMIN -u root -p 5900:5900  -v $(pwd):/src -v /home/Automation/:/root/.m2 mcr.microsoft.com/playwright:bionic &
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • I don't know either. you seem to be evaluating or using karate, I think Ive made it clear this is advanced usage that we need help with - so if you are unable to do the necessary research and / or contribute code, please look for other options. – Peter Thomas Aug 30 '21 at 02:47

1 Answers1

1

So, first of all, you need to actually provide a working example of what you're trying to achieve.

What I understand from your question, is that you're trying to give the url for the tests from docker command in the terminal.

Since Playwright v1.13.0, there is a baseURL option available. You can utilise that in this way probably

In your config.js file, you can have this

import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  use: {
    baseURL: process.env.URL,
  },
};
export default config;

In your command for running docker, you can then pass as

docker run --name playwright -it --rm --ipc=host --cap-add=SYS_ADMIN -u root -p 5900:5900 -URL=whateverURLyouwant -v $(pwd):/src -v /home/Automation/:/root/.m2 mcr.microsoft.com/playwright:bionic &

Also, one point I would like to mention is that, you should not use root user for your executions. Using root as user in docker is not a recommended practice. Instead use the pwuser that is already created by the given image.

demouser123
  • 4,108
  • 9
  • 50
  • 82