Celina yang
Celina yang

Reputation: 59

Start Selenium server automatically for e2e testing

I followed this SO post to set up my Gruntfile. If I manually downloaded Selenium standalone and specified its location in the file, my test runs successfully. Since I would like to automate this process, I tried the following configuration:

protractor_webdriver: {
  start: {
    options: {
      path: 'node_modules/grunt-protractor-runner/node_modules/protractor/bin/',
      command: 'webdriver-manager start'
    }
  }
};

grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.registerTask('test', ['protractor_webdriver:start','protractor:run'])

Is there a way to avoid downloading manually? I tried the above but when I ran it, I got the warning:

Running "protractor_webdriver:start" (protractor_webdriver) task
Verifying property protractor_webdriver.start exists in config...OK
File: [no files]
Options: path="node_modules/grunt-protractor-runner/node_modules/protractor/bin/", command="webdriver-manager start", keepAlive=false
Starting Selenium server
>> Selenium Standalone is not present. Install with webdriver-manager update --standalone

So I still need to download the selenium standalone server manually?
Or maybe I missed some configuration here?

Upvotes: 1

Views: 3361

Answers (2)

NG Ninza
NG Ninza

Reputation: 11

You can run Protractor without Selenium by specifying

directConnect: true

in your respective Protractor configuration file (e.g. protractor.conf.js).

Upvotes: 1

Saifur
Saifur

Reputation: 16201

Protractor is a wrapper around WebDriverJS.

It's a nodejs program that interacts with Selenium Server and specific Browser drivers (e.g. ChromeDriver, IEDriver).

So, without using selenium server (at least for IE), you cannot run tests written with protractor. Test scripts send commands to the Selenium Server, which in turn then communicates with the browser driver. See this for a description of the architecture.

In a nutshell, without having started a Selenium server instance beforehand, nothing will happen.

Upvotes: 1

Related Questions