Reputation: 2277
I am trying to use protractor within my project to automate the use of a browser.
I have been unable to get Protractor recognized in my project, as when I run my code I get the following errors:
error TS2503: Cannot find namespace 'protractor'.
Previously, I was able to reference protractor generated in my /typings directory during runtime. However, when I run my project now, the file is no longer generated since I upgraded my version of protractor to the latest.
I have also tried the solution mentioned online:
import {browser} from 'protractor'
UPDATE: I do not need to explicitly import protractor after upgrading to TypeScript 2.0.0, however, my code still displays errors but the tests now execute as expected.
[ts] Cannot find name 'browser'
[ts] Cannot find namespace 'protractor'.
Is it possible to remove these errors?
Upvotes: 3
Views: 1966
Reputation: 2277
I found that the issue in the end was to do with my /typings folder. After completely deleting it, AND recreating/generating my tsd.json, this solved the issue.
Protractor is not needed in the typings folder, but other dependencies are, and can now reference it using
import { browser } from 'protractor'
and:
import protractor = require('protractor')
Upvotes: 1