Regarding Protractor script execution in intelliJ - Unresolved function or method describe()

All, I was able to set up Protractor scripts in IntelliJ and able to execute it successfully. Below is the sample code.

 

// spec.js
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');

expect(browser.getTitle()).toEqual('Super Calculator');
});
});

In Intellij editor, I can see below warning on "describe". I can see similar warning on "it","browser" and "expect" as well.

Unresolved function or method describe()

I would like to know how I remove this warnings as it seems that IDE requires further configuration. Also, I require to know whether this IDE has autocomplete/intellisense for coding Protractor.

 

0
10 comments

To get describe, it, etc. resolved, try installinjg jasmine Typescript stubs using Settings | Languages & Frameworks | JavaScript | Libraries, Download

browser, etc. should normally be resolved to types in node_modules/protractor/built/index.d.ts

3

> I cannot locate "libraries" under "Java script"

You are editing settings for new projects. And libraries can only be added to existing projects. Open your project and then use Preferences | Languages & Frameworks | JavaScript | Libraries, Download to add a library

1
Avatar
Permanently deleted user

Highly appreciate ...quick response.. This addressed my issue.

1
Avatar
Permanently deleted user

I just tried navigating to install Jasmine as described in the post.

Settings | Languages & Frameworks | JavaScript | Libraries, Download

But, I cannot locate "libraries" under "Java script". May be I am doing wrong navigation After I access "Configure->Preferences" (see attached screens). Then, I navigated to Languages & Frameworks | JavaScript . I could not see "Library" under Java script.
)

0
Avatar
Permanently deleted user

Thanks Elena!

Adding jasmine library helped me to resolve describe, it and expect, but still browser, element, by, sendKeys, etc... are not resolved.

I checked my node_modules/protractor/built/index.d.ts file and this is what I see in it:

import { ElementHelper, ProtractorBrowser } from './browser';
import { ElementArrayFinder, ElementFinder } from './element';
import { ProtractorExpectedConditions } from './expectedConditions';
import { ProtractorBy } from './locators';
import { PluginConfig, ProtractorPlugin } from './plugins';
import { Ptor } from './ptor';
export { ActionSequence, Browser, Builder, Button, Capabilities, Capability, error, EventEmitter, FileDetector, Key, logging, promise, Session, until, WebDriver, WebElement, WebElementPromise } from 'selenium-webdriver';
export { ElementHelper, ProtractorBrowser } from './browser';
export { Config } from './config';
export { ElementArrayFinder, ElementFinder } from './element';
export { ProtractorExpectedConditions } from './expectedConditions';
export { Locator, ProtractorBy } from './locators';
export { Ptor } from './ptor';
export { Runner } from './runner';
export declare type PluginConfig = PluginConfig;
export declare type ProtractorPlugin = ProtractorPlugin;
export declare let utils: {
firefox: any;
http: any;
remote: any;
};
export declare let Command: any;
export declare let CommandName: any;
export declare let protractor: Ptor;
export declare let browser: ProtractorBrowser;
export declare let $: (search: string) => ElementFinder;
export declare let $$: (search: string) => ElementArrayFinder;
export declare let element: ElementHelper;
export declare let By: ProtractorBy;
export declare let by: ProtractorBy;
export declare let ExpectedConditions: ProtractorExpectedConditions;

 

Is there anything else I need to change/do to get full Protractor scripting recognition?

 

Regards!

 

 

0

Make sure that node_modules/protractor/built folder is not excliuded from indexing (check its color in Project tool window)

 

0
Avatar
Permanently deleted user

I just checked it and node_modules/protractor/built is not excluded, but it is not in my project either:

 

Do I need to add "C:\Users\luisabrn\AppData\Roaming\npm\node_modules\protractor\built" folder to my project?

0

You need to install protractor locally in your prohect. The IDE won't use your global modules for types resolving

0
Avatar
Permanently deleted user

Thanks Elena!

0

You can also add global protractor to your Project as External Library.

Settings | Languages & Frameworks | JavaScript | Libraries, Add...

 
0

Please sign in to leave a comment.