Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Protractor with google.com?

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!

like image 466
Eric the Red Avatar asked Apr 21 '15 19:04

Eric the Red


1 Answers

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!

like image 50
Sakshi Singla Avatar answered Oct 04 '22 14:10

Sakshi Singla