6

My tests are throwing the following error. It used to run fine before. Please advise.

My Config file:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  allScriptsTimeout: 20000,
  baseUrl: 'https://mylink/#/',

   // frameworks to use
    frameworks: ['jasmine'],

// Capabilities to be passed to the webdriver instance.

  multiCapabilities: [{
    'browserName': 'chrome'
 //}, {
   // 'browserName': 'firefox'
    //
   }],

 // Spec patterns are relative to the current working directory.
  specs: [
    'tests/HomePage.js'
  ],


  onPrepare: function() {
    browser.driver.manage().window().maximize();
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
      new jasmine.JUnitXmlReporter('xmloutput', true. true));
  },

  jasmineNodeOpts: {
    showColors: true
  }

}

My Spec file:

// spec.js
describe('MyTest homepage', function() {
   var ptor;
   require('protractor-linkuisref-locator')(protractor);

  beforeEach(function() {
    browser.ignoreSynchronization = true;
    ptor = protractor.getInstance();
    browser.rootEl = 'div';
    //browser.driver.manage().window().setSize(1280, 1024);
    browser.debugger();
  });


  it('Should enter homepage url and credentials', function() {
     browser.get('/#/');
     element(by.name('userName')).sendKeys('');
     element(by.name('password')).sendKeys('');
     element(by.xpath("//button[@class=' btn orange small wide']")).click();
  });

  it('Should the title contain', function() {
    expect(browser.getTitle()).toEqual('');

  });

  it('Should click on the PowerGuide', function() {
     element(by.linkUiSref('locator')).click();
     ptor.sleep(100); 
     //expect(ptor.getCurrentUrl(locator)).toEqual('');
    });

   it('Should click on Month', function() {
     element(by.id('month-tab')).click();
     ptor.sleep(100);

    });


   //it('Should load the images', function() {
   // element(by.css('.pure-u-1-2')).click();
    //var icons = element.all(by.css('.pure-u-1-2')).click();
    //icons.first().click();
   //});


});

This is the error I am getting.

        seleniumProcess.pid: 1380
14:43:45.163 INFO - Launching a standalone server
Setting system property webdriver.chrome.driver to C:\Users\sramamoorthy\AppData\Roaming\npm\node_modules\protractor\sel
enium\chromedriver.exe
14:43:45.342 INFO - Java: Oracle Corporation 25.40-b25
14:43:45.342 INFO - OS: Windows 7 6.1 amd64
14:43:45.373 INFO - v2.45.0, with Core v2.45.0. Built from revision 5017cb8
14:43:45.597 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
14:43:45.597 INFO - Version Jetty/5.1.x
14:43:45.597 INFO - Started HttpContext[/selenium-server,/selenium-server]
14:43:45.779 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@23223dd8
14:43:45.781 INFO - Started HttpContext[/wd,/wd]
14:43:45.781 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
14:43:45.781 INFO - Started HttpContext[/,/]
14:43:45.789 INFO - Started SocketListener on 0.0.0.0:4444
14:43:45.789 INFO - Started org.openqa.jetty.jetty.Server@133314b
14:44:41.384 INFO - Executing: [new session: Capabilities [{count=1, browserName=chrome}]])
14:44:41.399 INFO - Creating a new session for Capabilities [{count=1, browserName=chrome}]
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 44385
Only local connections are allowed.
14:44:43.309 INFO - Done: [new session: Capabilities [{count=1, browserName=chrome}]]
14:44:43.567 INFO - Executing: [set script timeoutt: 20000])
14:44:43.584 INFO - Executing: [delete session: 64c8dac4-559f-416d-b77b-78c5184b6538])
14:44:43.590 INFO - Done: [set script timeoutt: 20000]
14:44:45.303 INFO - Done: [delete session: 64c8dac4-559f-416d-b77b-78c5184b6538]

Test Error: This is the error I am getting where i am calling the Conf.js file from

Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
[launcher] Error: TypeError: undefined is not a function
    at
  at Object.exports.run (C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\frameworks\jasmine.js:6
2:17)
    at C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:326:35
    at _fulfilled (C:\Users\sr\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:797:54)
    at self.promiseDispatch.done (C:\Users\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:
826:30)
    at Promise.promise.promiseDispatch (C:\Users\ppData\Roaming\npm\node_modules\protractor\node_modules\q
\q.js:759:13)
[launcher] Process exited with error code 100
user2744620
  • 439
  • 1
  • 9
  • 21

3 Answers3

3

There is a typo inside onPrepare():

onPrepare: function() {
    browser.driver.manage().window().maximize();
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
      new jasmine.JUnitXmlReporter('xmloutput', true. true));
    //                                          HERE^
},

You meant instead:

jasmine.getEnv().addReporter(
    new jasmine.JUnitXmlReporter('xmloutput', true, true));
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • It still doesn't run. Just noticed that selenium server is not starting. I tried installing using webdriver-manager update --standalone multiple times. I am getting the following message when i initialize webdriver session C:\MyTest>webdriver-manager start seleniumProcess.pid: 1380 – user2744620 May 12 '15 at 21:44
  • @user2744620 sounds like a different error to me. Difficult to tell but what if you replace `frameworks: ['jasmine'],` with `frameworks: 'jasmine',`? – alecxe May 12 '15 at 21:45
  • I updated the body with complete error code. I tried what you suggested as well. I am still having the same issue. Please help – user2744620 May 12 '15 at 22:09
0
Error: TypeError: undefined is not a function
    at
  at Object.exports.run (C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\frameworks\jasmine.js:6

The error is from the library. I think you might missed some dependencies that the library requires.

David S.
  • 10,578
  • 12
  • 62
  • 104
  • As far as I know.. I have installed all the required modules. What do you recommend that I should be doing – user2744620 May 13 '15 at 02:05
  • I installed HTMLreporter and deleted XML output lines. Now, I see the chrome browser launching and attempting to login. After entering the user name and password, I get TypeError: Undefined is not a function. My code is the same as above...I want to progress on developing more. I am stuck now :( – user2744620 May 13 '15 at 05:59
  • try to remove the `onPrepare` definition? – David S. May 13 '15 at 07:03
  • Yes.. It worked when i removed. But what is wrong with OnPrepare function. I changed it to this one still when i run i am getting syntax error. I don't see anything wrong onPrepare: function() { browser.driver.manage().window().maximize(); jasmine.getEnv().addReporter(new HtmlReporter({ baseDirectory: '/MySolarCity/Screenshots' })); – user2744620 May 15 '15 at 17:26
  • Code runs now but i don't get any html report back – user2744620 May 15 '15 at 23:50
0

Removing this line fixed a similar problem for me:

seleniumAddress: 'http://localhost:4444/wd/hub',
Dmitri Zaitsev
  • 13,548
  • 11
  • 76
  • 110