symfony / panther

A browser testing and web crawling library for PHP and Symfony
MIT License
2.94k stars 222 forks source link

Using the hosts chrome for tests within a docker container #512

Open siemendev opened 3 years ago

siemendev commented 3 years ago

Hi folks! I've implemented panther for e2e tests in one of my projects within a php container and it works flawlessly so far. I've installed chromium and the chromedriver on the dev image and running tests works perfectly fine locally and within our CI.

I wonder if it's possible to execute my testsuite from within the container with panther addressing the chrome/chromedriver from the container's host. I would love to start my testsuite with PANTHER_NO_HEADLESS=1 so I could debug easier when writing tests. The container has no UI so I guess I need to configure the system to start the host's chrome instead of the container's chromium. I do know that the host is available as host.docker.internal from within the container, but I don't know where (or even if) I can configure panther to use the host's chrome/chromedriver instead of the one from within the container.

Any ideas on this?

keldrox commented 3 years ago

I need the same thing you want...

1) Executed chromedriver on the host. 2) Dockerfile open port 9515 3) Execute code inside the container

$client = Client::createSeleniumClient('http://127.0.0.1:9515/wd/hub'); $client->request('GET', 'https://www.xxxxxxxx.loc'); echo $client->getCrawler()->html();

Failed to connect to 127.0.0.1 port 9515: Connection refused

Any ideas on this? Thank you

domis86 commented 3 years ago

have you tried https://stackoverflow.com/questions/31324981/how-to-access-host-port-from-docker-container/43541732#43541732 or other answers from there?

siemendev commented 2 years ago

Actually I can access the host from the container via host.docker.internal, but the problem is that the driverdriver cannot be located on the host... panther requires the chromedriver to be on the same system as panther runs (therefore within the container) since I cannot configure the driverdriver to be located at host.docker.internal

keldrox commented 2 years ago

@siemendev check this https://github.com/symfony/panther/issues/505