4
votes

I'm wondering if it is possible to run a setup of angular cli project with cucumber e2e tests, using protractor steps, without using a selenium server. When I search for such configurations, I only find ones that have a seleniumAddress setup.

So, is it possible to run it without it?

2

2 Answers

4
votes

Requires a server running W3C WebDriver specifications

From your question, can you run Protractor without a selenium server? Yes, if you are using a browser driver that follows the W3C WebDriver specification. So setting directConnect: true (angular-cli default) in your configuration file basically tells Protractor to launch the driver binary, then Protractor creates a driver provider to talk to that binary.

Driver provider options

The driver providers can be different. Your question also referred to the seleniumAddress. So how does this work? Basically, Protractor reads your configuration file and decides which driver provider to launch. If you are not using directConnect and have decided to use the seleniumAddress option in your configuration then you could be either launching an attached session or a hosted driver. Attaching a session means that you have a previous session running and Protractor will launch tests against the session id. Hosted means that you have started your test against a running selenium standalone server. Usually the selenium standalone server is http://localhost:4444.

There are other types of driver providers to help launch your tests and if you follow the conditional in buildDriverProvider method, you can pick and chose which one you want to launch. Obviously (from the conditional), if you have directConnect and seleniumAddress, you will launch with a direct connect driver provider.

A quick note on webdriver-manager

Also a quick note on webdriver-manager. If you plan to launch your Protractor tests on Firefox, you'll need to download Gecko driver. If you use the seleniumAddress option, you'll also need to download the selenium-standalone server. The angular-cli only downloads chromedriver with the command, webdriver-manager update --standalone false --gecko false. To download the rest, simply remove the flags that are set to false: webdriver-manager update

Cucumber in your configuration

So finally you want cucumber with Protractor. Protractor supports cucumber as a custom framework. You'll need to require the protractor-cucumber-framework. Hopefully you have found this on the configuration in the Protractor-cookbook.

You should add the following to your configuration to get cucumber working:

framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
  compiler: "ts:ts-node/register",
  monochrome: true,
  strict: true,
  plugin: ["pretty"],
  require: ['../../stepdefinitions/*.ts', '../../support/*.ts'],
  //tags help us execute specific scenarios of feature files
  tags: '@AddScenario,@SubtractScenario,@MultiplyScenario,@DivideScenario,@ModulusScenario'
}
1
votes

You can run protractor tests without selenium server by using directConnect: true in your protractor config. But note this option only currently works with Chrome and Firefox.