You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/WebDriver.md
+92-47Lines changed: 92 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,19 +33,72 @@ Warning. Using PHAR file and composer in the same project can cause unexpected e
33
33
34
34
35
35
Run tests in real browsers using the W3C [WebDriver protocol](https://www.w3.org/TR/webdriver/).
36
+
There are multiple ways of running browser tests using WebDriver:
36
37
37
-
### Local Testing in Chrome and/or Firefox
38
+
### Selenium (Recommended)
38
39
39
-
To run tests in a real browser you need:
40
-
* The browser itself: Chrome/Chromium and/or Firefox
41
-
* The appropriate driver:
42
-
*[ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/getting-started) for Chrome/Chromium
43
-
*[GeckoDriver](https://github.com/mozilla/geckodriver) for Firefox
44
-
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.
45
-
* Optional: Selenium Standalone Server (see below)
40
+
* Java is required
41
+
* NodeJS is required
42
+
43
+
The fastest way to get started is to [Install and launch Selenium using selenium-standalone NodeJS package](https://www.npmjs.com/package/selenium-standalone).
44
+
45
+
Launch selenium standalone in separate console window:
46
+
47
+
{% highlight yaml %}
48
+
selenium-standalone start
49
+
50
+
{% endhighlight %}
51
+
52
+
Update configuration in `acceptance.suite.yml`:
53
+
54
+
{% highlight yaml %}
55
+
56
+
modules:
57
+
enabled:
58
+
- WebDriver:
59
+
url: 'http://localhost/'
60
+
browser: chrome # 'chrome' or 'firefox'
61
+
62
+
{% endhighlight %}
63
+
64
+
### Headless Chrome Browser
65
+
66
+
To enable headless mode (launch tests without showing a window) for Chrome browser using Selenium use this config in `acceptance.suite.yml`:
67
+
68
+
{% highlight yaml %}
69
+
70
+
modules:
71
+
enabled:
72
+
- WebDriver:
73
+
url: 'http://localhost/'
74
+
browser: chrome
75
+
capabilities:
76
+
chromeOptions:
77
+
args: ["--headless", "--disable-gpu"]
78
+
79
+
{% endhighlight %}
80
+
81
+
### Headless Selenium in Docker
82
+
83
+
Docker can ship Selenium Server with all its dependencies and browsers inside a single container.
84
+
Running tests inside Docker is as easy as pulling [official selenium image](https://github.com/SeleniumHQ/docker-selenium) and starting a container with Chrome:
85
+
86
+
{% highlight yaml %}
87
+
docker run --net=host selenium/standalone-chrome
88
+
89
+
{% endhighlight %}
90
+
91
+
By using `--net=host` allow Selenium to access local websites.
92
+
93
+
### Local Chrome and/or Firefox
94
+
95
+
Tests can be executed directly throgh ChromeDriver or GeckoDriver (for Firefox). Consider using this option if you don't plan to use Selenium.
46
96
47
97
#### ChromeDriver
48
98
99
+
* Download and install [ChromeDriver](https://sites.google.com/chromium.org/driver/downloads?authuser=0)
100
+
* Launch ChromeDriver in a separate console window: `chromedriver --url-base=/wd/hub`.
101
+
49
102
Configuration in `acceptance.suite.yml`:
50
103
51
104
{% highlight yaml %}
@@ -66,11 +119,12 @@ modules:
66
119
{% endhighlight %}
67
120
See here for additional [Chrome options](https://sites.google.com/a/chromium.org/chromedriver/capabilities)
68
121
69
-
Before running the tests, you need to start ChromeDriver in a separate console window: `chromedriver --url-base=/wd/hub`.
70
-
Or you can enable the [RunProcess extension](https://codeception.com/extensions#RunProcess) to start/stop ChromeDriver automatically.
71
122
72
123
#### GeckoDriver
73
124
125
+
*[GeckoDriver])(https://github.com/mozilla/geckodriver/releases) must be installed
126
+
* Start GeckoDriver in a separate console window: `geckodriver`.
127
+
74
128
Configuration in `acceptance.suite.yml`:
75
129
76
130
{% highlight yaml %}
@@ -91,43 +145,6 @@ modules:
91
145
{% endhighlight %}
92
146
See here for [Firefox capabilities](https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities#List_of_capabilities)
93
147
94
-
Before running the tests, you need to start GeckoDriver in a separate console window: `geckodriver`.
95
-
Or you can enable the [RunProcess extension](https://codeception.com/extensions#RunProcess) to start/stop GeckoDriver automatically.
96
-
97
-
#### Selenium
98
-
99
-
On top of ChromeDriver/GeckoDriver you may also use Selenium Standalone Server for more options.
For additional `capabilities`, see above. Selenium 3.8 renamed the `chromeOptions` capability to `goog:chromeOptions`.
115
-
116
-
Before running the tests, you need to start GeckoDriver in a separate console window: `java -jar "/path/to/selenium-server-standalone-xxx.jar"`
117
-
To locate the ChromeDriver binary use `-Dwebdriver.chrome.driver=./chromedriver`, for GeckoDriver use `-Dwebdriver.gecko.driver=./geckodriver`.
118
-
119
-
#### Headless Selenium in Docker
120
-
121
-
Docker can ship Selenium Server with all its dependencies and browsers inside a single container.
122
-
Running tests inside Docker is as easy as pulling [official selenium image](https://github.com/SeleniumHQ/docker-selenium) and starting a container with Chrome:
123
-
124
-
{% highlight yaml %}
125
-
docker run --net=host selenium/standalone-chrome
126
-
127
-
{% endhighlight %}
128
-
129
-
By using `--net=host` we allow selenium to access local websites.
130
-
131
148
### Cloud Testing
132
149
133
150
Cloud Testing services can run your WebDriver tests in the cloud.
@@ -177,6 +194,34 @@ you should use a tunnel application provided by a service.
177
194
browserstack.local: true # for local testing
178
195
179
196
{% endhighlight %}
197
+
198
+
#### LambdaTest
199
+
200
+
1. Create an account at [LambdaTest](https://www.lambdatest.com/) to get your username and access key
201
+
2. In the module configuration use the format `username`:`access key`@hub.lambdatest.com' for `host`
202
+
3. Configure `os` and `os_version` under `capabilities` to define the operating System
203
+
4. If your site is available only locally or via VPN you should use a tunnel app. In this case add capabilities.setCapability("tunnel",true);.
204
+
205
+
{% highlight yaml %}
206
+
207
+
modules:
208
+
enabled:
209
+
- WebDriver:
210
+
url: http://mysite.com
211
+
host: '<username>:<accesskey>@hub.lambdatest.com'
212
+
build: <yourbuildname>
213
+
name: <yourtestname>
214
+
port: 80
215
+
browser: chrome
216
+
capabilities:
217
+
os: Windows
218
+
os_version: 10
219
+
browser_version: 86
220
+
resolution: 1366x768
221
+
tunnel: true # for local testing
222
+
223
+
{% endhighlight %}
224
+
180
225
#### TestingBot
181
226
182
227
1. Create an account at [TestingBot](https://testingbot.com/) to get your key and secret
0 commit comments