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
{{ message }}
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/browser-setup.md
+67-66Lines changed: 67 additions & 66 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
-
Setting up your Browser
1
+
Setting Up Your Browser
2
2
=======================
3
3
4
-
Protractor is agnostic to how you set up your browser - it wraps WebDriverJS, so all browser setup for WebDriverJS applies. This doc serves as a collection for information surrounding how to set up browsers.
4
+
Protractor works with [Selenium WebDriver](http://docs.seleniumhq.org/docs/03_webdriver.jsp), a browser automation framework. Selenium WebDriver supports several browser implementations or [drivers](http://docs.seleniumhq.org/docs/03_webdriver.jsp#selenium-webdriver-s-drivers) which are discussed below.
5
5
6
6
Browser Support
7
7
---------------
8
-
Protractor uses WebDriver, so Protractor support for a particular browser is tied to the capabilities available in the Driver for that browser. Notably, Protractor requires the driver to implement asynchronous script execution.
8
+
Protractor support for a particular browser is tied to the capabilities available in the driver for that browser. Notably, Protractor requires the driver to implement asynchronous script execution.
9
9
10
10
Protractor supports the two latest major versions of Chrome, Firefox, Safari, and IE.
11
11
@@ -26,27 +26,28 @@ Protractor supports the two latest major versions of Chrome, Firefox, Safari, an
26
26
Configuring Browsers
27
27
--------------------
28
28
29
-
In your Protractor configuration file, all browser set up is done within the `capabilities`JSON object. This is passed directly to the WebDriver Builder.
29
+
In your Protractor config file (see [referenceConf.js](/docs/referenceConf.js)), all browser setup is done within the `capabilities` object. This object is passed directly to the WebDriver builder ([builder.js](https://code.google.com/p/selenium/source/browse/javascript/webdriver/builder.js)).
30
30
31
-
See [the DesiredCapabilities Docs](https://code.google.com/p/selenium/wiki/DesiredCapabilities) for full information on which properties are available.
32
31
33
-
Switching to a browser besides Chrome
34
-
-------------------------------------
32
+
See [DesiredCapabilities](https://code.google.com/p/selenium/wiki/DesiredCapabilities) for full information on which properties are available.
33
+
34
+
Using Browsers Other Than Chrome
35
+
--------------------------------
35
36
36
-
Simply set a different browser name in the capabilites object
37
+
To use a browser other than Chrome, simply set a different browser name in the capabilities object.
37
38
38
39
```javascript
39
40
capabilities: {
40
41
'browserName':'firefox'
41
42
}
42
43
```
43
44
44
-
You may need to install a separate binary to run another browser, such as IE or Android.
45
+
You may need to install a separate binary to run another browser, such as IE or Android. For more information, see [SeleniumHQ Downloads](http://docs.seleniumhq.org/download/).
45
46
46
-
Adding Chrome specific options
47
+
Adding Chrome-Specific Options
47
48
------------------------------
48
49
49
-
Chrome options are nested in the `chromeOptions` object. A full list of options is at [the chromedriver site](https://sites.google.com/a/chromium.org/chromedriver/capabilities). For example, to show an FPS counter in the upper right, your configuration would look like this:
50
+
Chrome options are nested in the `chromeOptions` object. A full list of options is at the [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/capabilities) site. For example, to show an FPS counter in the upper right, your configuration would look like this:
50
51
51
52
```javascript
52
53
capabilities: {
@@ -56,12 +57,12 @@ capabilities: {
56
57
}
57
58
},
58
59
```
59
-
If running with chromeOnly and chromeOptions together, chromeOptions.args and chromeOptions.extensions are required due to [Issue 6627](https://code.google.com/p/selenium/issues/detail?id=6627&thanks=6627&ts=1385488060) of selenium-webdriver currently(@2.37.0). So in order to avoid the issue, you may simply set them(or one of them) to an empty array.
60
+
If running with `chromeOnly` and `chromeOptions` together, chromeOptions.args and chromeOptions.extensions are required due to [Issue 6627](https://code.google.com/p/selenium/issues/detail?id=6627&thanks=6627&ts=1385488060) of selenium-webdriver currently(@2.37.0). So in order to avoid the issue, you may simply set them(or one of them) to an empty array.
60
61
61
-
Testing against multiple browsers
62
+
Testing Against Multiple Browsers
62
63
---------------------------------
63
64
64
-
If you would like to test against multiple browsers at once, use the multiCapabilities configuration option.
65
+
If you would like to test against multiple browsers, use the `multiCapabilities` configuration option.
65
66
66
67
```javascript
67
68
multiCapabilities: [{
@@ -71,15 +72,15 @@ multiCapabilities: [{
71
72
}]
72
73
```
73
74
74
-
Protractor will run tests in parallel against each set of capabilities. Please note that if multiCapabilities is defined, the runner will ignore the `capabilities` configuration.
75
+
Protractor will run tests in parallel against each set of capabilities. Please note that if `multiCapabilities` is defined, the runner will ignore the `capabilities` configuration.
75
76
76
77
77
-
How to set up Protractor with Appium - Android/Chrome
78
+
Setting Up Protractor with Appium - Android/Chrome
78
79
-------------------------------------
79
-
###### Set up
80
+
###### Setup
80
81
* Install Java SDK (>1.6) and configure JAVA_HOME (Important: make sure it's not pointing to JRE).
81
-
* Follow http://spring.io/guides/gs/android/ to install and set up Android developer environment. Do not set up Android Virtual Device as instructed here
82
-
* From commandline, ```android avd``` and then install an AVD, taking note of the following
82
+
* Follow http://spring.io/guides/gs/android/ to install and set up Android developer environment. Do not set up Android Virtual Device as instructed here.
83
+
* From commandline, ```android avd``` and then install an AVD, taking note of the following:
83
84
* Start with an ARM ABI
84
85
* Enable hardware keyboard: ```hw.keyboard=yes```
85
86
* Enable hardware battery: ```hw.battery=yes```
@@ -109,24 +110,24 @@ Available Android Virtual Devices:
109
110
Tag/ABI: default/armeabi-v7a
110
111
Skin: WXGA800-7in
111
112
```
112
-
* Follow http://ant.apache.org/manual/index.html to install ant and set up the environment
113
+
* Follow http://ant.apache.org/manual/index.html to install ant and set up the environment.
113
114
* Follow http://maven.apache.org/download.cgi to install mvn (Maven) and set up the environment.
114
-
* NOTE: Appium suggests installing Maven 3.0.5 (I haven't tried later versions, but 3.0.5 works for sure)
115
-
* Install Appium using node ```npm install -g appium```. Make sure you don't install as sudo or else Appium will complain
116
-
* You can do this either if you installed node without sudo, or you can chown the global node_modules lib and bin directories
117
-
* Start emulator manually (at least the first time) and unlock screen
115
+
* NOTE: Appium suggests installing Maven 3.0.5 (I haven't tried later versions, but 3.0.5 works for sure).
116
+
* Install Appium using node ```npm install -g appium```. Make sure you don't install as sudo or else Appium will complain.
117
+
* You can do this either if you installed node without sudo, or you can chown the global node_modules lib and bin directories.
118
+
* Start emulator manually (at least the first time) and unlock screen.
118
119
119
120
```shell
120
121
> emulator -avd LatestAndroid
121
122
```
122
-
* Your devices should show up under adb now
123
+
* Your devices should show up under adb now:
123
124
124
125
```shell
125
126
> adb devices
126
127
List of devices attached
127
128
emulator-5554 device
128
129
```
129
-
* If the AVD does not have chrome (and it probably won't if it just created), you need to install it
130
+
* If the AVD does not have chrome (and it probably won't if it just created), you need to install it:
130
131
* You can get v34.0.1847.114 from http://www.apk4fun.com/apk/1192/
131
132
* Once you download the apk, install to your AVD as such:
132
133
@@ -135,21 +136,21 @@ emulator-5554 device
135
136
2323 KB/s (30024100 bytes in 12.617s)
136
137
Success
137
138
```
138
-
* If you check your AVD now, it should have Chrome
139
+
* If you check your AVD now, it should have Chrome.
139
140
140
-
###### Running test
141
-
* Ensure app is running if testing local app (Skip if testing public website)
141
+
###### Running Tests
142
+
* Ensure app is running if testing local app (Skip if testing public website):
142
143
143
144
```shell
144
145
> ./scripts/web-server.js
145
146
Starting express web server in /workspace/protractor/testapp on port 8000
146
147
```
147
-
* If your AVD isn't already started from the setup, start it now
148
+
* If your AVD isn't already started from the setup, start it now:
148
149
149
150
```shell
150
151
> emulator -avd LatestAndroid
151
152
```
152
-
* Start Appium
153
+
* Start Appium:
153
154
154
155
```shell
155
156
> appium
@@ -159,7 +160,7 @@ info: socket.io started
159
160
```
160
161
*Note Appium listens to port 4723 instead of 4444*
-under capabilities: browserName is '', device is 'android', and app is 'chrome'
186
-
-baseUrl is 10.0.2.2 instead of localhost because it is used to access the localhost of the host machine in the android emulator
187
-
-selenium address is using port 4723
185
+
*Note the following:*
186
+
-under capabilities: browserName is '', device is 'android', and app is 'chrome'
187
+
-baseUrl is 10.0.2.2 instead of localhost because it is used to access the localhost of the host machine in the android emulator
188
+
-selenium address is using port 4723
188
189
189
-
How to set up Protractor with Appium - iOS/Safari
190
+
Setting Up Protractor with Appium - iOS/Safari
190
191
-------------------------------------
191
-
###### Set up
192
+
###### Setup
192
193
* Install Java SDK (>1.6) and configure JAVA_HOME (Important: make sure it's not pointing to JRE).
193
-
* Follow http://ant.apache.org/manual/index.html to install ant and set up the environment
194
+
* Follow http://ant.apache.org/manual/index.html to install ant and set up the environment.
194
195
* Follow http://maven.apache.org/download.cgi to install mvn (Maven) and set up the environment.
195
-
* NOTE: Appium suggests installing Maven 3.0.5 (I haven't tried later versions, but 3.0.5 works for sure)
196
-
* Install Appium using node ```npm install -g appium```. Make sure you don't install as sudo or else Appium will complain
197
-
* You can do this either if you installed node without sudo, or you can chown the global node_modules lib and bin directories
196
+
* NOTE: Appium suggests installing Maven 3.0.5 (I haven't tried later versions, but 3.0.5 works for sure).
197
+
* Install Appium using node ```npm install -g appium```. Make sure you don't install as sudo or else Appium will complain.
198
+
* You can do this either if you installed node without sudo, or you can chown the global node_modules lib and bin directories.
198
199
199
-
###### Running test
200
-
* Ensure app is running if testing local app (Skip if testing public website)
200
+
###### Running Tests
201
+
* Ensure app is running if testing local app (Skip if testing public website):
201
202
202
203
```shell
203
204
> ./scripts/web-server.js
204
205
Starting express web server in /workspace/protractor/testapp on port 8000
205
206
```
206
-
* Start Appium
207
+
* Start Appium:
207
208
208
209
```shell
209
210
> appium
210
211
info: Welcome to Appium v1.0.0-beta.1 (REV 6fcf54391fb06bb5fb03dfcf1582c84a1d9838b6)
211
212
info: Appium REST http interface listener started on 0.0.0.0:4723
212
213
info: socket.io started
213
214
```
214
-
*Note Appium listens to port 4723 instead of 4444*
215
+
*Note: Appium listens to port 4723 instead of 4444.*
215
216
216
-
* Configure protractor, i.e.
217
+
* Configure protractor:
217
218
218
219
iPhone:
219
220
```javascript
@@ -258,17 +259,17 @@ exports.config = {
258
259
};
259
260
260
261
```
261
-
*note three things:*
262
-
-note capabilities
263
-
-baseUrl is localhost (not 10.0.2.2)
264
-
-selenium address is using port 4723
262
+
*Note the following:*
263
+
-note capabilities
264
+
-baseUrl is localhost (not 10.0.2.2)
265
+
-selenium address is using port 4723
265
266
266
-
How to set up Protractor with Selendroid
267
+
Setting Up Protractor with Selendroid
267
268
-------------------------------------
268
-
###### Set up
269
+
###### Setup
269
270
* Install Java SDK (>1.6) and configure JAVA_HOME (Important: make sure it's not pointing to JRE).
270
-
* Follow http://spring.io/guides/gs/android/ to install and set up Android developer environment. Do not set up Android Virtual Device as instructed here
271
-
*from commandline, 'android avd' and then follow Selendroid's recommendation (http://selendroid.io/setup.html#androidDevices). Take note of the emulator accelerator. Here's an example:
271
+
* Follow http://spring.io/guides/gs/android/ to install and set up Android developer environment. Do not set up Android Virtual Device as instructed here.
272
+
*From commandline, 'android avd' and then follow Selendroid's recommendation (http://selendroid.io/setup.html#androidDevices). Take note of the emulator accelerator. Here's an example:
272
273
273
274
```shell
274
275
> android list avd
@@ -281,36 +282,36 @@ Available Android Virtual Devices:
281
282
Skin: WVGA800
282
283
```
283
284
284
-
###### Running test
285
-
* Ensure app is running if testing local app (Skip if testing public website)
285
+
###### Running Tests
286
+
* Ensure app is running if testing local app (Skip if testing public website):
286
287
287
288
```shell
288
289
> ./scripts/web-server.js
289
290
Starting express web server in /workspace/protractor/testapp on port 8000
290
291
```
291
292
292
-
* Start emulator manually (at least the first time)
293
+
* Start emulator manually (at least the first time):
293
294
294
295
```shell
295
296
> emulator -avd myAvd
296
297
HAX is working and emulator runs in fast virt mode
297
298
```
298
299
299
-
*note the last line that tells you the emulator accelerator is running*
300
+
*Note: The last line that tells you the emulator accelerator is running.*
* Once selendroid is started, you should be able to go to "http://localhost:4444/wd/hub/status" and see your device there, i.e.
308
+
* Once selendroid is started, you should be able to go to "http://localhost:4444/wd/hub/status" and see your device there:
308
309
309
310
```javascript
310
311
{"value":{"os":{"name":"Mac OS X","arch":"x86_64","version":"10.9.2"},"build":{"browserName":"selendroid","version":"0.9.0"},"supportedDevices":[{"emulator":true,"screenSize":"WVGA800","avdName":"Hank","androidTarget":"ANDROID19"}],"supportedApps":[{"mainActivity":"io.selendroid.androiddriver.WebViewActivity","appId":"io.selendroid.androiddriver:0.9.0","basePackage":"io.selendroid.androiddriver"}]},"status":0}
311
312
```
312
313
313
-
* Configure protractor, i.e.
314
+
* Configure protractor:
314
315
315
316
```javascript
316
317
exports.config= {
@@ -330,13 +331,13 @@ exports.config = {
330
331
};
331
332
```
332
333
333
-
*note two things:*
334
-
-browserName is 'android'
335
-
-baseUrl is 10.0.2.2 instead of localhost because it is used to access the localhost of the host machine in the android emulator
334
+
*Note the following:*
335
+
-browserName is 'android'
336
+
-baseUrl is 10.0.2.2 instead of localhost because it is used to access the localhost of the host machine in the android emulator
336
337
337
338
338
-
PhantomJS
339
-
-------------------------------------
339
+
Setting up PhantomJS
340
+
--------------------
340
341
In order to test locally with [PhantomJS](http://phantomjs.org/), you'll need to either have it installed globally, or relative to your project. For global install see the [PhantomJS download page](http://phantomjs.org/download.html). For relative install run: `npm install --save-dev phantomjs`.
341
342
342
343
Add phantomjs to the driver capabilities, and include a path to the binary if using local installation:
0 commit comments