1

How to run single test in protractor selenium.

describe('Login page', function() {

beforeEach(function() {
  browser.ignoreSynchronization = true;
  ptor = protractor.getInstance();
});

it('should contain navigation items', function(){
  //test case code here
});

it('should login the user successfully', function(){ 
  //test case code here
})
});

I would like to run only single test. I can run it using fit but I would like to do it from command line and without changing test.

Also how can I run singe test using Grunt?

rohitkadam19
  • 1,734
  • 5
  • 21
  • 39

1 Answers1

6

You can use --grep command-line argument:

protractor conf.js --grep="navigation"
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Hi, this is solving my purpose but I am getting other tests as Pending in result and xml report is showing other tests as well. ANy way to avoid it? – rohitkadam19 Sep 12 '15 at 00:14
  • @rohitkadam19 glad to hear it helps. Are you using `jasmine-reporters`, specifically terminal and junit reporters? – alecxe Sep 12 '15 at 01:15
  • yes, I am using `jasmin-reporters` and al so I am running it using Grunt-protractor. Can we use it with grunt and protractor? – rohitkadam19 Sep 12 '15 at 01:17
  • @rohitkadam19 sure, reporters are configured inside the protractor config's `onPrepare()`. I mean that these issues can actually be `jasmine-reporters`-specific..try creating an issue in it's issue tracker https://github.com/larrymyers/jasmine-reporters/issues or post a separate question here about the reporters and grep option.. – alecxe Sep 12 '15 at 01:21
  • I have created issue - https://github.com/larrymyers/jasmine-reporters/issues/118. and how can I run --grep option with Grunt in protractor. Appreciate your help! – rohitkadam19 Sep 12 '15 at 01:37
  • I think you can make use of passing your grep values as a task argument, see http://stackoverflow.com/questions/18623739/pass-options-to-a-grunt-task-while-running-it and set the "grep" inside grunt-protractor-runner task options (https://github.com/gruntjs/grunt-contrib-connect#options) ..not tested.. – alecxe Sep 12 '15 at 02:04