codeThinker123
codeThinker123

Reputation: 692

How to fix 'browser' being undefined when importing protractor in Angular

When importing protrator in an Angualr application I try to use the function browser.waitForAngularEnabled.

When I run the code I get the error:

E/launcher - Error: TypeError: Cannot read property 'waitForAngularEnabled' of undefined

I am importing the browser in this way

   const { browser } = require('protractor');

When I click through to the protractor module in VS code I can see the browser object in there but in runtime this error is thrown.

Upvotes: 0

Views: 629

Answers (1)

Yevhen Laichenkov
Yevhen Laichenkov

Reputation: 8652

In Protractor, you are provided with a global browser object. So you don't need to require it, the browser object is accessible without requiring it.

Solution: Just remove the require and it will work.

Note: You have to import it only if you are working with typescript.

Upvotes: 1

Related Questions