Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manage Protractor tests with a single Gulp task

I'm trying to get e2e testing going with on my angular project using Gulp.

I'm able to get it working, but only if I manually launch a standalone selenium server using webdriver-manager start in a seperate terminal window.

Ideally I would like my gulp task to manage starting and stopping the server so as to not add more overhead for my team to run these tests.

I got set up following the instructions here:

https://github.com/mllrsohn/gulp-protractor

They describe 2 options for starting the selenium server. One is to set up a gulp task which appears to do the same thing as webdriver-manager start:

gulp.task('webdriver_standalone', require("gulp-protractor").webdriver_standalone);

This works, but not when I have my e2eTest task invoke it as a dependency. I have to run gulp webdriver_standalone in a seperate terminal window.

I cannot understand the other suggested option.

point to the selenium jar in the protractor config file

These instructions require a path to the selenium-server-standalone jar, in protractors node_modules (./node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar), but my node_modules/protractor/ directory does not have such a jar (or a selenium sub-directory at all)

The instructions for Running Protractor without a plugin seem to have the same problem of having to run the selenium server in another terminal window.

Is there a way to get this set up so that a single gulp task starts the standalone server, runs the tests, and shuts it down with no other intervention?

like image 933
Zach Lysobey Avatar asked Jun 01 '15 21:06

Zach Lysobey


1 Answers

When you run Protractor you have several options regarding Selenium WebDriver (remember that WebDriver is web-service written in Java):

  1. Run with Protractor with remote (standalone) service. It can be either local or on different machine. If Selenium is on different machine then your web app should be publicly available, not just localhost. If you choose to use standalone Selenium service then you configure your config file/Gulp task with seleniumAddress option.
  2. "Ask" Protractor to run Selenium for you. In this case Protractor will run Selenium WebDriver with the Jar file you provide in seleniumServerJar configuration.
  3. Do not use Selenium WD. Use direct connect instead, which is compatible with Chrome and (probably) Firefox only.

In your case simply run:

./node_modules/protractor/bin/webdriver-manager update

It will download Selenium. Then point config to the right jar.

like image 154
Igor Shubovych Avatar answered Sep 21 '22 00:09

Igor Shubovych