6

google.com isn't an Angular app, but Protractor should still be able to test it, right? I've been trying to do a simple test of a search, but keep running to errors.

the spec:

browser.ignoreSynchronization = true;

describe('Google Demo', function() {
  it('Should Search', function() {
    browser.get('http://google.com/');
    browser.wait(element(By.id('q')).isPresent);
    element(By.id('q')).sendKeys('please work');
  });
});

the error is:

Failures:

1) Google Demo Should Search
 Message: TypeError: Cannot read property 'count' of undefined

What am I doing wrong? I'd appreciate any help!

Eric the Red
  • 5,364
  • 11
  • 49
  • 63

2 Answers2

15

Since it's a non-Angular app, you need to use browser.driver instead of just browser. GitHub Link for non-angular app

browser.ignoreSynchronization = true;

describe('Google Demo', function() {
  it('Should Search', function() {
    browser.driver.get('http://google.com/');   
    browser.driver.findElement(by.name('q')).sendKeys('please work');
  });
});

This is working on my system!

Pang
  • 9,564
  • 146
  • 81
  • 122
Sakshi Singla
  • 2,462
  • 1
  • 18
  • 34
0

this also works for non angular apps

browser.waitForAngularEnabled(false);

describe('Google search', function() {
    it('should search a text as GURU99', function() {
    browser.waitForAngularEnabled(false);
    browser.get('https://www.google.com');
    element(by.name("q")).sendKeys('test')
    browser.sleep(5000);

});
});
Mani
  • 1,068
  • 3
  • 13
  • 27