borkweb / products-test-automation

Other
3 stars 0 forks source link

Tutorial: How to view the browser while running acceptance tests #71

Open Luc45 opened 4 years ago

Luc45 commented 4 years ago

1) Download Selenium server on your host machine and run it with java -jar /path/to/selenium.jar. [1], you should see something like:

➜  ~ java -jar /usr/share/selenium-server/selenium-server-standalone.jar
17:53:46.211 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
17:53:46.297 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2020-05-22 17:53:46.372:INFO::main: Logging initialized @454ms to org.seleniumhq.jetty9.util.log.StdErrLog
17:53:46.647 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
17:53:46.736 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444

2) Add 127.0.0.1 wordpress.test to your /etc/hosts file (or %WinDir%\System32\drivers\etc\hosts in Windows) 3) In .env.testing.tric, set:

WP_URL=http://wordpress.test:8888
WP_CHROMEDRIVER_URL=http://wordpress.test:8888

You also need to set CHROMEDRIVER_HOST to point to an IP address where the docker container will be able to reach your host machine. This will depend on your operating system and docker version:

CHROMEDRIVER_HOST in Linux A) 172.16.238.1
CHROMEDRIVER_HOST in Mac A) Docker 18.03.0-ce+ and Docker compose 1.20.1+: host.docker.internal B) Docker 17.12.0-ce+ and Docker compose 1.18.0+: docker.for.mac.host.internal C) Docker 17.06.0-ce+ and Docker compose 1.14.0+: docker.for.mac.localhost
CHROMEDRIVER_HOST in Windows A) Docker 18.03.0-ce+ and Docker compose 1.20.1+: docker.for.win.host.internal or host.docker.internal B) Docker 17.06.0-ce+ and Docker compose 1.14.0+: docker.for.win.host.localhost

Now, when you run acceptance tests, you should see the browser popping up! :)

image

[1] How to download and run the Selenium Server on Manjaro ``` sudo pacman -S selenium-server-standalone java -jar /usr/share/selenium-server/selenium-server-standalone.jar ```
Luc45 commented 4 years ago

To improve: use a local .env.testing.tric alternative. I'm open to suggestions on how to approach that. (.env.tric.local doesn't seem to work for me)

lucatume commented 4 years ago

Better use Selenoid, that will be part of tric.