-
Notifications
You must be signed in to change notification settings - Fork 41
/
selenium_containers.py
59 lines (45 loc) · 1.61 KB
/
selenium_containers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import docker
container_time_zone = os.getenv('CONTAINERTZ', 'TZ=US/Mountain')
opera_docker_version = os.getenv(
'OPERADOCKERVERSION', 'selenium/standalone-opera:latest')
chrome_docker_version = os.getenv(
'CHROMEDOCKERVERSION', 'selenium/standalone-chrome:latest')
firefox_docker_version = os.getenv(
'FIREFOXDOCKERVERSION', 'selenium/standalone-firefox:latest')
def start_firefox():
client = docker.from_env()
client.containers.run(
firefox_docker_version,
ports={'4444/tcp': 4444, '5900/tcp': 5900},
volumes={'/dev/shm': {'bind': '/dev/shm', 'mode': 'rw'}, },
detach=True,
remove=True,
auto_remove=True,
environment=[container_time_zone])
def start_chrome():
client = docker.from_env()
client.containers.run(
chrome_docker_version,
ports={'4444/tcp': 4444, '5900/tcp': 5900},
volumes={'/dev/shm': {'bind': '/dev/shm', 'mode': 'rw'}, },
detach=True,
remove=True,
auto_remove=True,
environment=[container_time_zone])
def start_opera():
client = docker.from_env()
client.containers.run(
opera_docker_version,
ports={'4444/tcp': 4444, '5900/tcp': 5900},
volumes={'/dev/shm': {'bind': '/dev/shm', 'mode': 'rw'}, },
detach=True,
remove=True,
auto_remove=True,
environment=[container_time_zone])
def stop_selenium_containers():
client = docker.from_env()
image_name = "selenium/standalone"
for container in client.containers.list():
if image_name in str(container.image.tags):
container.stop()