WILT: Sundry docker

Today at work was inheriting a project from someone else, who used pytest and behave to test a PHP application. Owie. Continuing my compartmentalisation, I built pytest/ behave into a docker container to pass the code into to test. I also have the app I'm testing running its own docker to keep that as close to production as possible.

Learning 1: Hostfile

I adjust my local hostfile to have official work URLS point to my local machine for testing work. I tried to edit the pytest in the app container, it told me to sod off. So how can I get my pytest to know the urls that the app is using? The add-host parameter to Docker:

1docker run --add-host [new-url]:host-gateway ...

So it uses host-gateway to access the docker service as whole's host which is my machine, which then gets piped down into the appropriate container. It worked!

Learning 2: Waiting for Godot elements

To wait for elements to exist or not exist, there's a specific wait driver

1    w = WebDriverWait(self.driver, 5)
2    w.until(expected_conditions.invisibility_of_element_located((By.ID, "IDOfElementToGoAwayPlease")))

Learning 3: Firefox accepting insecure certs

I'm testing locally behind a dummy SSL gateway with a self signed certificate. Firefox (rightly) doesn't like that, so to test I have to assure it.

1    options = Options()
2    options.headless = True
3    options.accept_insecure_certs = True
4    self.driver = webdriver.Firefox(options=options)

Learning 4: Running the test

I'm putting this here less of a learning, more of a reminder that my previous volume-based mounting of tests works, and continues to work, and I should remember it at some point.

1docker run --add-host [host]:host-gateway  -i --rm -v [FullPath]/pytest:/pytest -t pytest pytest --screenshot=on --screenshot_path=on /pytest/

Learning 5: Git of these containers?

I was wondering if I should put these various Dockerised test tool groups up on Github or Bitbucket to share/ keep track of/ improve. Thoughts?