|
51 | 51 | /**
|
52 | 52 | * Run tests in real browsers using the W3C [WebDriver protocol](https://www.w3.org/TR/webdriver/).
|
53 | 53 | *
|
54 |
| - * ## Local Testing |
| 54 | + * ## Local Testing in Chrome and/or Firefox |
55 | 55 | *
|
56 |
| - * ### Browsers: Chrome and/or Firefox |
57 |
| - * |
58 |
| - * First, you need to install the browser itself: Chrome and/or Firefox. |
59 |
| - * * To run tests in Chrome/Chromium, you need to install [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/getting-started). |
60 |
| - * * To use Firefox, install [GeckoDriver](https://github.com/mozilla/geckodriver). |
61 |
| - * If you want to use both, consider setting up a dedicated [Codeception environment](https://codeception.com/docs/07-AdvancedUsage#Environments) for each. |
62 |
| - * |
63 |
| - * ### Selenium |
64 |
| - * |
65 |
| - * To run Selenium Server you need [Java](https://www.java.com/) as well as Chrome or Firefox browser installed. |
66 |
| - * |
67 |
| - * 1. Download [Selenium Standalone Server](http://docs.seleniumhq.org/download/) |
68 |
| - * 2. Launch the Selenium Server: `java -jar selenium-server-standalone-3.xx.xxx.jar`. To locate Chromedriver binary use `-Dwebdriver.chrome.driver=./chromedriver` option. For Geckodriver use `-Dwebdriver.gecko.driver=./geckodriver`. |
69 |
| - * 3. Configure this module (in `acceptance.suite.yml`) by setting `url` and `browser`: |
70 |
| - * |
71 |
| - * ```yaml |
72 |
| - * modules: |
73 |
| - * enabled: |
74 |
| - * - WebDriver: |
75 |
| - * url: 'http://localhost/' |
76 |
| - * browser: chrome # 'chrome' or 'firefox' |
77 |
| - * ``` |
78 |
| - * |
79 |
| - * Launch Selenium Server before executing tests. |
80 |
| - * |
81 |
| - * ``` |
82 |
| - * java -jar "/path/to/selenium-server-standalone-xxx.jar" |
83 |
| - * ``` |
| 56 | + * To run tests in a real browser you need: |
| 57 | + * * The browser itself: Chrome/Chromium and/or Firefox |
| 58 | + * * The appropriate driver: |
| 59 | + * * [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/getting-started) for Chrome/Chromium |
| 60 | + * * [GeckoDriver](https://github.com/mozilla/geckodriver) for Firefox |
| 61 | + * If you want to use both Chrome and Firefox, consider setting up a dedicated [Codeception environment](https://codeception.com/docs/07-AdvancedUsage#Environments) for each. |
| 62 | + * * Optional: Selenium Standalone Server (see below) |
84 | 63 | *
|
85 | 64 | * ### ChromeDriver
|
86 | 65 | *
|
87 |
| - * To run tests in Chrome/Chromium you may connect to ChromeDriver directly, without using Selenium Server. |
88 |
| - * |
89 |
| - * 1. Install [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/getting-started). |
90 |
| - * 2. Launch ChromeDriver: `chromedriver --url-base=/wd/hub` |
91 |
| - * 3. Configure this module to use ChromeDriver port: |
| 66 | + * Configuration in `acceptance.suite.yml`: |
92 | 67 | *
|
93 | 68 | * ```yaml
|
94 |
| - * modules: |
95 |
| - * enabled: |
96 |
| - * - WebDriver: |
97 |
| - * url: 'http://localhost/' |
98 |
| - * window_size: false # disabled in ChromeDriver |
99 |
| - * port: 9515 |
100 |
| - * browser: chrome |
101 |
| - * capabilities: |
102 |
| - * "goog:chromeOptions": # additional chrome options |
| 69 | + * modules: |
| 70 | + * enabled: |
| 71 | + * - WebDriver: |
| 72 | + * url: 'http://localhost/' |
| 73 | + * window_size: false # disabled in ChromeDriver |
| 74 | + * port: 9515 |
| 75 | + * browser: chrome |
| 76 | + * capabilities: |
| 77 | + * chromeOptions: |
| 78 | + * args: ["--headless", "--disable-gpu"] # Run Chrome in headless mode |
| 79 | + * prefs: |
| 80 | + * download.default_directory: "..." |
103 | 81 | * ```
|
| 82 | + * See here for additional [Chrome options](https://sites.google.com/a/chromium.org/chromedriver/capabilities) |
104 | 83 | *
|
105 |
| - * Additional [Chrome options](https://sites.google.com/a/chromium.org/chromedriver/capabilities) can be set in `goog:chromeOptions` capabilities. Note that Selenium 3.8 renamed this capability from `chromeOptions` to `goog:chromeOptions`. |
| 84 | + * Before running the tests, you need to start ChromeDriver in a separate console window: `chromedriver --url-base=/wd/hub`. |
| 85 | + * Or you can enable the [RunProcess extension](https://codeception.com/extensions#RunProcess) to start/stop ChromeDriver automatically. |
106 | 86 | *
|
107 | 87 | * ### GeckoDriver
|
108 | 88 | *
|
109 |
| - * To run tests in Firefox you may connect to GeckoDriver directly, without using Selenium Server. |
110 |
| - * |
111 |
| - * 1. Install [GeckoDriver](https://github.com/mozilla/geckodriver). |
112 |
| - * 2. Launch GeckoDriver: `geckodriver` |
113 |
| - * 3. Configure this module: |
| 89 | + * Configuration in `acceptance.suite.yml`: |
114 | 90 | *
|
115 | 91 | * ```yaml
|
116 | 92 | * modules:
|
|
121 | 97 | * path: ''
|
122 | 98 | * capabilities:
|
123 | 99 | * acceptInsecureCerts: true # allow self-signed certificates
|
| 100 | + * moz:firefoxOptions: |
| 101 | + * args: ["-headless"] # Run Firefox in headless mode |
| 102 | + * prefs: |
| 103 | + * intl.accept_languages: "de-AT" # Set HTTP-Header `Accept-Language: de-AT` for requests |
124 | 104 | * ```
|
| 105 | + * See here for [Firefox capabilities](https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities#List_of_capabilities) |
| 106 | + * |
| 107 | + * Before running the tests, you need to start GeckoDriver in a separate console window: `geckodriver`. |
| 108 | + * Or you can enable the [RunProcess extension](https://codeception.com/extensions#RunProcess) to start/stop GeckoDriver automatically. |
| 109 | + * |
| 110 | + * ### Selenium |
| 111 | + * |
| 112 | + * On top of ChromeDriver/GeckoDriver you may also use Selenium Standalone Server for more options. |
| 113 | + * |
| 114 | + * 1. Install [Java](https://www.java.com/) |
| 115 | + * 2. Download [Selenium Standalone Server](http://docs.seleniumhq.org/download/) |
| 116 | + * 3. Configuration in `acceptance.suite.yml`: |
| 117 | + * |
| 118 | + * ```yaml |
| 119 | + * modules: |
| 120 | + * enabled: |
| 121 | + * - WebDriver: |
| 122 | + * url: 'http://localhost/' |
| 123 | + * browser: chrome # 'chrome' or 'firefox' |
| 124 | + * ``` |
| 125 | + * For additional `capabilities`, see above. Selenium 3.8 renamed the `chromeOptions` capability to `goog:chromeOptions`. |
| 126 | + * |
| 127 | + * Before running the tests, you need to start GeckoDriver in a separate console window: `java -jar "/path/to/selenium-server-standalone-xxx.jar"` |
| 128 | + * To locate the ChromeDriver binary use `-Dwebdriver.chrome.driver=./chromedriver`, for GeckoDriver use `-Dwebdriver.gecko.driver=./geckodriver`. |
125 | 129 | *
|
126 | 130 | * ### Headless Selenium in Docker
|
127 | 131 | *
|
|
0 commit comments