Zeeshan Hassan Memon
Zeeshan Hassan Memon

Reputation: 8325

simple protractor test failing with unexpected result

I am trying to run protractor test agains url http://na5.keylo.co/, target is:

  1. fill _model field with data 'Oracle Corporation'
  2. click Search button
  3. expect result against search is count 508

spec code:

describe('keylocations home page', function () {
it('should search condos', function () {
    browser.get('http://na5.keylo.co/');

    element(by.model('_model')).sendKeys("Oracle Corporation");
    element(by.css('.search__block.search__submit')).click();


    var condos = element.all(by.repeater('condo in scrollResults'));
    expect(condos.count()).toEqual(508);

    // this also can be used to get desired test completed
    //expect(element(by.css('.bar__number'))).toEqual("508 condos found");

});
});

Problem :

I always get 0 in by.repeater result, whereas I see exact result when I use on browser manually, Its simple but I am making mistake don't know what?

EDIT:

Using conf.js as suggested by @Gunderson :

//this works and sows success
browser.driver.wait(browser.driver.isElementPresent(by.css('.bar__number')));


//this fails with following error log
expect(element(by.css('.bar__number')).getText()).toEqual("508 condos found");


//this also fails with following error log
browser.driver.wait(expect(element(by.css('.bar__number')).getText()).toEqual("508 condos found"));

Using the selenium server at http://localhost:4444/wd/hub [launcher] Running 1 instances of WebDriver Spec started Started WARNING - more than one element found for locator by.model("_model") - the first result will be used

keylocations home page ? should search condos - Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.5.2/ng/test"

F


  • Failures *

1) keylocations home page should search condos - Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.5.2/ng/test"

Executed 1 of 1 spec (1 FAILED) in 14 secs.

Failures: 1) keylocations home page should search condos Message: Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.5.2/ng/test" Stack: Error: Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.5.2/ng/te st" at C:\Users\Hair\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:101:16 at Promise.invokeCallback_ (C:\Users\Hair\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1329:14) at TaskQueue.execute_ (C:\Users\Hair\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2790:14) at TaskQueue.executeNext_ (C:\Users\Hair\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2773:21)

1 spec, 1 failure Finished in 14.407 seconds [launcher] 0 instance(s) of WebDriver still running [launcher] chrome #01 failed 1 test(s) [launcher] overall: 1 failed spec(s) [launcher] Process exited with error code 1

Upvotes: 1

Views: 781

Answers (1)

Gunderson
Gunderson

Reputation: 3268

Seems like there is something wrong with your local settings to me. I copied your code and it passed (well failed because the number was wrong, but it retrieved the # of condos).

describe('keylocations home page', function () {
  it('should search condos', function () {
    browser.get('http://na5.keylo.co/');

    element(by.model('_model')).sendKeys("Oracle Corporation");
    element(by.css('.search__block.search__submit')).click();


    var condos = element.all(by.repeater('condo in scrollResults'));
    expect(condos.count()).toEqual(508);

    // this also can be used to get desired test completed
    //expect(element(by.css('.bar__number'))).toEqual("508 condos found");
  });
});

This returns: console

Seems you have something wrong locally. I'll paste a link to my config file https://gist.github.com/anonymous/7a682f45999c0377013e409fe6dd4e24 - other than that, I suggest you update Protractor, webDriver, and Jasmine.

I'm on Protractor 2.5.1 and Jasmine 2.3.4.

Upvotes: 1

Related Questions