30

There is a way to run and debug protractor web-tests in WebStorm. I just want to share this answer here

S Panfilov
  • 16,641
  • 17
  • 74
  • 96

7 Answers7

53
  1. Get the node path (Type which node in your terminal)
  2. In the WebStorm: Click on "Edit configurations" - the dropdown to the left of the "Run" button (green arrow like a "play" button)
  3. Click on the "Add button" (green +) to add a new Node configuration. Select "Node.js"
  4. Fill the params:

Node interpreter: Full path to Node.js (from step 1)

Working directory: home directory for the protractor tests.

Javascript file: Full path to node_modules/protractor/lib/cli.js

Application parameters: Full path to protractor-conf.js

Now you be able to run and debug tests by clicking on "Run" or "Debug" buttons on the top of IDE

S Panfilov
  • 16,641
  • 17
  • 74
  • 96
  • Hmm.. may be few steps didn't clear? Please give more info, I'll try to help you – S Panfilov Feb 03 '14 at 07:35
  • yeah, didn't work for me either; posted at length about it here- http://stackoverflow.com/q/21992414/537913 – J. Ed Feb 24 '14 at 15:50
  • In my case it doesn't start the tests if I use "Debug" (bug icon) and it starts the tests if I use "Run" (play icon), but it doesn't stop anywhere. – Diego Pamio Feb 25 '14 at 15:52
  • Looks like with doing the "Debug" option (bug icon), it adds --debug-brk=62532 --nolazy to the node command line. – Diego Pamio Feb 25 '14 at 15:54
  • 1
    An additional thing, in this video (http://www.youtube.com/watch?v=VLMyI7QKcwg) looks like web storm identifies the breakpoint with the usual "tick" inside, whereas in my case, it doesn't. – Diego Pamio Feb 25 '14 at 15:57
  • I think it should be **protractor.conf.js** *not* protractor-conf.js. – camden_kid Sep 24 '14 at 16:08
  • In my case - it "runs" fine. while debugging, it gives error "Process finished with exit code 139" I am on Mac. – Nitin Jadhav Apr 12 '16 at 07:08
  • In my case the javascript file is the following: node_modules/protractor/bin/protractor – Ferenc Takacs Nov 22 '16 at 11:44
15

It works! Here are my settings

enter image description here

David Dehghan
  • 22,159
  • 10
  • 107
  • 95
3

I was experiencing the same problems described by comments to S.Panfilov's answer, i.e., running protractor in WebStorm worked fine, but the debugging process got stuck somewhere.

The issue is described here. It was occurring under Mac OS X with version 0.20.1 of protractor, and node v0.10.26.

The problem is solved in version 0.22.

  • Update protractor to the latest version (>= 0.22) using npm
  • Run again: node_modules/protractor/bin/webdriver-manager update
  • In WebStorm configure 'Your Protractor Conf' as described by S.Panfilov in his answer
  • Set breakpoints in your protractor test file (watch this video first)
  • Launch "Run > Debug 'Your Protractor Conf'" from WebStorm
  • Enjoy debugging
guidoman
  • 1,071
  • 2
  • 11
  • 20
2

For mac OSX: enter image description here on the left you can see tests folder structure

pbaranski
  • 22,778
  • 19
  • 100
  • 117
1

Worked for me. It was looking for the protractor.conf.js in the wrong folder. Had to look up a couple dirs.

Application parameters: ../../protractor.conf.js

Chester Rivas
  • 692
  • 7
  • 16
1

Like some of the other responses here, I found that I could run in release but couldn't run in Debug and it would just hang at some point. I found that I had the conf file set to target two browsers and it seems that this was too much for the debugger and it would hang without any more info. Targeting only a single browser fixed this issue for me.

Andrew
  • 2,390
  • 1
  • 15
  • 9
1

By the way if you need to pass additional parameters here is the configuration you need

  • Select ‘Node.js’ configuration from the list
  • Name: ‘Protractor’
  • Node interpreter: ‘C:\Program Files\nodejs\node.exe’
  • Node parameters: ‘’
  • Working directory:
  • JavaScript file: ‘~\AppData\Roaming\npm\node_modules\protractor\built\cli.js’
  • Application parameters, this is where you specify path to your conf, relatively to working directory^ and then parameters like this: ‘e2e/settings/configs/protractor.custom.conf.js --baseUrl="https://stage.mysite.com" --params.login="testuser" --params.password="test_USER00"’
  • Environment variables: ‘’

This config works great in my project, where we solely rely on async/await syntax

Sergey Pleshakov
  • 7,964
  • 2
  • 17
  • 40