Skip to content

Commit 66375d7

Browse files
committed
updated docs
1 parent a358ee0 commit 66375d7

File tree

2 files changed

+236
-191
lines changed

2 files changed

+236
-191
lines changed

docs/modules/WebDriver.md

Lines changed: 92 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,72 @@ Warning. Using PHAR file and composer in the same project can cause unexpected e
3333

3434

3535
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:
3637

37-
### Local Testing in Chrome and/or Firefox
38+
### Selenium (Recommended)
3839

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.
4696

4797
#### ChromeDriver
4898

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+
49102
Configuration in `acceptance.suite.yml`:
50103

51104
{% highlight yaml %}
@@ -66,11 +119,12 @@ modules:
66119
{% endhighlight %}
67120
See here for additional [Chrome options](https://sites.google.com/a/chromium.org/chromedriver/capabilities)
68121

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.
71122

72123
#### GeckoDriver
73124

125+
* [GeckoDriver])(https://github.com/mozilla/geckodriver/releases) must be installed
126+
* Start GeckoDriver in a separate console window: `geckodriver`.
127+
74128
Configuration in `acceptance.suite.yml`:
75129

76130
{% highlight yaml %}
@@ -91,43 +145,6 @@ modules:
91145
{% endhighlight %}
92146
See here for [Firefox capabilities](https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities#List_of_capabilities)
93147

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.
100-
101-
1. Install [Java](https://www.java.com/)
102-
2. Download [Selenium Standalone Server](http://docs.seleniumhq.org/download/)
103-
3. Configuration in `acceptance.suite.yml`:
104-
105-
{% highlight yaml %}
106-
107-
modules:
108-
enabled:
109-
- WebDriver:
110-
url: 'http://localhost/'
111-
browser: chrome # 'chrome' or 'firefox'
112-
113-
{% endhighlight %}
114-
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-
131148
### Cloud Testing
132149

133150
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.
177194
browserstack.local: true # for local testing
178195

179196
{% 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>:<access key>@hub.lambdatest.com'
212+
build: <your build name>
213+
name: <your test name>
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+
180225
#### TestingBot
181226

182227
1. Create an account at [TestingBot](https://testingbot.com/) to get your key and secret

0 commit comments

Comments
 (0)