blob: 32bf39d5063efdd5b5a4aff7bceb32dcccf7a414 (
plain)
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
|
Check that Docker is installed and your user can run Docker:
```
$ docker run --rm hello-world
```
Docker should print a success message, if not, review your Docker installation.
Create a virtualenv and install `testcontainers` with `selenium` support:
```
$ python3 -m venv selenium_testcontainers_venv
$ . selenium_testcontainers_venv/bin/activate
$ pip install -U pip
$ pip install testcontainers[selenium]
```
Use in a Python terminal:
```
$ python
>>> from testcontainers import selenium
>>> from selenium.webdriver import DesiredCapabilities
>>> chrome = selenium.BrowserWebDriverContainer(DesiredCapabilities.CHROME)
>>> chrome.start()
>>> webdriver = chrome.get_driver()
>>> ...
```
Use in code:
```
from testcontainers import selenium
from selenium.webdriver import DesiredCapabilities
with BrowserWebDriverContainer(DesiredCapabilities.CHROME) as chrome:
webdriver = chrome.get_driver()
...
```
|