In geometry class, we used protractors to measure angles. In web application development, we use the tool Protractor to measure angular (and other non angular) web applications. Protractor runs tests in a real browser (just as your users will).
If your users will not be able to do something (e.g., they can not click on a hidden button), then Protractor will also not be able to do it. The most important configuration option that you should consider is the browser connection – what browsers to test and on what operating systems. Let us assume that you create a test-runner Machine with protractor installed and configured. How does this test-runner Machine open and control the browser? What browsers should it run against?
You want the test browser to be as similar as possible to the user’s browser. You should use your business sense to determine which browsers protractor should run against. For example, your application might collect browser metrics. In general, supporting more browsers is a good thing, because it increases the number of people who can use your application. It’s not free, however.
Knowing which browser(s) protractor should run against will help you decide which of the three basic browser connection types are right for you:
Direct Connect
Protractor can connect directly to the Firefox and Chrome browsers. If you only need to support Firefox and/or Chrome running on the same operating system as the protractor system, then this is an easy option.
Assume that your application is used in house by your client’s employees. The client has specified Chrome as the official supported browser. Then you can install Chrome on your test-runner Machine and protractor will find it, connect to it, open it, run tests, and close it without you having to do much configuration.
If your client decided to approve Internet Explorer, then direct connect would no longer be appropriate.
It is also important to note that the browser will be run on the same Machine as protractor. If most of your users are running Chrome on Windows and your test-runner is Linux, then there is a risk for operating system specific regression.
Selenium Server
Selenium Server is probably the most popular way to connect protractor to the browser(s). Selenium Server is a proxy between Protractor and the browser. The Selenium Server does not need to run in the same computer as your protractor runner.
In the previous example, you could continue to run your test-runner on a Linux Machine but create a separate Windows Machine with Chrome installed. Install and run Selenium Server on the Windows Machine. Then configure protractor on the test-runner with the Selenium Server URL. Protractor will connect to the Windows Machine and use Chrome on the Windows Machine to run your tests.
If your users use multiple versions of Windows, Macs, and other systems, then you can create Machines for each version. Install and run Selenium server on each Machine. Protractor can repeat the tests over all supported operating systems.
Sauce Labs
Selenium Server could provide all the coverage you need, but you might find it tedious to setup and maintain so many browser/operating system combinations. You might be interested in running tests one time on a browser. (For example, if your client is considering officially supporting Internet Explorer, then it might be useful to know how much work that would generate).
You can outsource this task to Sauce Labs. (There are multiple competitors to Sauce Labs in the same space, but support for Sauce Labs is built into Protractor.) The obvious advantage of Sauce Labs is that it is easy to test on any specific browser/operating system combination. The disadvantages are that you will either have to make your test application public facing or configure it so that Sauce Labs has access. You will have to budget for Sauce Labs, because it is not a free service.
Coming Up Next
After you have decided which browser(s) you will support and how to connect them, I will explain how to run protractor headlessly for easier, automated scheduled testing.