Skip to content

Commit fdf7051

Browse files
committed
added more options
1 parent 50e284d commit fdf7051

File tree

1 file changed

+74
-60
lines changed

1 file changed

+74
-60
lines changed

src/Codeception/Module/WebDriver.php

Lines changed: 74 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,66 @@
5050

5151
/**
5252
* Run tests in real browsers using the W3C [WebDriver protocol](https://www.w3.org/TR/webdriver/).
53+
* There are multiple ways of running browser tests using WebDriver:
5354
*
54-
* ## Local Testing in Chrome and/or Firefox
55+
* ## Selenium (Recommended)
5556
*
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)
57+
* * Java is required
58+
* * NodeJS is required
59+
*
60+
* The fastest way to get started is to [Install and launch Selenium using selenium-standalone NodeJS package](https://www.npmjs.com/package/selenium-standalone).
61+
*
62+
* Launch selenium standalone in separate console window:
63+
*
64+
* ```
65+
* selenium-standalone start
66+
* ```
6367
*
64-
* ### ChromeDriver
68+
* Update configuration in `acceptance.suite.yml`:
69+
*
70+
* ```yaml
71+
* modules:
72+
* enabled:
73+
* - WebDriver:
74+
* url: 'http://localhost/'
75+
* browser: chrome # 'chrome' or 'firefox'
76+
* ```
77+
*
78+
* ## Headless Chrome Browser
79+
*
80+
* To enable headless mode (launch tests without showing a window) for Chrome browser using Selenium use this config in `acceptance.suite.yml`:
81+
*
82+
* ```yaml
83+
* modules:
84+
* enabled:
85+
* - WebDriver:
86+
* url: 'http://localhost/'
87+
* browser: chrome
88+
* capabilities:
89+
* chromeOptions:
90+
* args: ["--headless", "--disable-gpu"]
91+
* ```
92+
*
93+
* ## Headless Selenium in Docker
94+
*
95+
* Docker can ship Selenium Server with all its dependencies and browsers inside a single container.
96+
* Running tests inside Docker is as easy as pulling [official selenium image](https://github.com/SeleniumHQ/docker-selenium) and starting a container with Chrome:
6597
*
98+
* ```
99+
* docker run --net=host selenium/standalone-chrome
100+
* ```
101+
*
102+
* By using `--net=host` allow Selenium to access local websites.
103+
*
104+
* ## Local Chrome and/or Firefox
105+
*
106+
* Tests can be executed directly throgh ChromeDriver or GeckoDriver (for Firefox). Consider using this option if you don't plan to use Selenium.
107+
*
108+
* ### ChromeDriver
109+
*
110+
* * Download and install [ChromeDriver](https://sites.google.com/chromium.org/driver/downloads?authuser=0)
111+
* * Launch ChromeDriver in a separate console window: `chromedriver --url-base=/wd/hub`.
112+
*
66113
* Configuration in `acceptance.suite.yml`:
67114
*
68115
* ```yaml
@@ -81,11 +128,12 @@
81128
* ```
82129
* See here for additional [Chrome options](https://sites.google.com/a/chromium.org/chromedriver/capabilities)
83130
*
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.
86131
*
87132
* ### GeckoDriver
88133
*
134+
* * [GeckoDriver])(https://github.com/mozilla/geckodriver/releases) must be installed
135+
* * Start GeckoDriver in a separate console window: `geckodriver`.
136+
*
89137
* Configuration in `acceptance.suite.yml`:
90138
*
91139
* ```yaml
@@ -103,41 +151,7 @@
103151
* intl.accept_languages: "de-AT" # Set HTTP-Header `Accept-Language: de-AT` for requests
104152
* ```
105153
* 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`.
129-
*
130-
* ### Headless Selenium in Docker
131-
*
132-
* Docker can ship Selenium Server with all its dependencies and browsers inside a single container.
133-
* Running tests inside Docker is as easy as pulling [official selenium image](https://github.com/SeleniumHQ/docker-selenium) and starting a container with Chrome:
134-
*
135-
* ```
136-
* docker run --net=host selenium/standalone-chrome
137-
* ```
138-
*
139-
* By using `--net=host` we allow selenium to access local websites.
140-
*
154+
*
141155
* ## Cloud Testing
142156
*
143157
* Cloud Testing services can run your WebDriver tests in the cloud.
@@ -193,20 +207,20 @@
193207
*
194208
* ```yaml
195209
* modules:
196-
enabled:
197-
- WebDriver:
198-
url: http://mysite.com
199-
host: '<username>:<access key>@hub.lambdatest.com'
200-
build: <your build name>
201-
name: <your test name>
202-
port: 80
203-
browser: chrome
204-
capabilities:
205-
os: Windows
206-
os_version: 10
207-
browser_version: 86
208-
resolution: 1366x768
209-
tunnel: true # for local testing
210+
* enabled:
211+
* - WebDriver:
212+
* url: http://mysite.com
213+
* host: '<username>:<access key>@hub.lambdatest.com'
214+
* build: <your build name>
215+
* name: <your test name>
216+
* port: 80
217+
* browser: chrome
218+
* capabilities:
219+
* os: Windows
220+
* os_version: 10
221+
* browser_version: 86
222+
* resolution: 1366x768
223+
* tunnel: true # for local testing
210224
* ```
211225
*
212226
* ### TestingBot

0 commit comments

Comments
 (0)