protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Protractor 3.1.1 doesn't run test for application having .debugInfoEnalbled(false)

Open ravitej-klair opened this issue 10 years ago • 6 comments

Pretty new here,

Recently upgraded to Protractor 3.1.1 and testing the debug feature (148f020)

I understand that the debug flag added in the protractor.js helps to run the tests for applications with .debugInfoEnabled(false);

But my test doesn't without the following hack browser.executeScript('window.name = "NG_ENABLE_DEBUG_INFO!"');

But wasn't this the whole point of upgrading to Protractor 3.1.1 so you don't have to do this?!

Any suggestions?

ravitej-klair avatar Mar 08 '16 00:03 ravitej-klair

It looks like that commit has the order wrong - Angular first checks if the string starts with NG_ENABLE_DEBUG_INFO, and then checks for the NG_DEFER_BOOTSTRAP string. Needs to be switched.

juliemr avatar Mar 08 '16 01:03 juliemr

Hi Guys,

I'm using protractor 3.2.2 now and still not able to run my test WITHOUT hacking it with browser.executeScript('window.name = "NG_ENABLE_DEBUG_INFO!"');

ravitej-klair avatar Apr 06 '16 17:04 ravitej-klair

I'm rolling back the associated PR since it is causing issues with older versions of Angular.

Note that if you are not using manual bootstrap, we should be able to turn on debug info by using Protractor's default set of mock modules. @ravitej-klair can you provide a test application that we can run against showing where this fails?

juliemr avatar Apr 21 '16 01:04 juliemr

I'm using Protratctor 3.2.2 and attempted to use elementExplorer. Here are the results of running various commands. For details on the setup, see this page: http://stackoverflow.com/questions/36851322/attempting-to-select-angular-component-element-and-getting-an-error?noredirect=1#comment61273847_36851322

> browser.executeScript('window.name = "NG_ENABLE_DEBUG_INFO!"'); null > element(by.css('state-selection-component')).getText() Error while waiting for Protractor to sync with the page: "Could not find testability for element." > element(by.css('state-selection-component')).getLocation() Error while waiting for Protractor to sync with the page: "Could not find testability for element." > element(by.css('state-selection-component')).isEnabled() Error while waiting for Protractor to sync with the page: "Could not find testability for element." > element(by.css('state-selection-component div > p')).isEnabled() Error while waiting for Protractor to sync with the page: "Could not find testability for element." >

machtyn avatar Apr 26 '16 14:04 machtyn

I noticed that the status and type was changed. I'm not sure if you need something more reproducible, but if it helps, here's what I did. Create a new folder (angular2play). Follow instructions on Angular 2 quick start guide, with the following addition to the package.json file: "devDependencies": { ..., "protractor": "^3.2.2", ... }

Run npm start which displayed the "My First Angular 2 App" text appropriately. In a new terminal, run protractor --elementExplorer Within elementExplorer run the following commands: > browser.get('http://localhost:3000') > element(by.css('my-app h1')).getText(); Error while waiting for Protractor to sync with the page: "Could not find testability for element."

See attached file for the result of > element(by.css('my-app h1')); elementResult.txt

This was performed on a MacOS (El Capitan 10.11.4). For the tutorial, I copied the text and pasted it in the files using Sublime Text (I decided to remove the IDE variable).

$ npm ls --depth=0 [email protected] /Users/machtyn/Projects/angular2play ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected]

machtyn avatar Apr 26 '16 18:04 machtyn

OH this is for Angular2. Angular2 does not respond to the NG_ENABLE_DEBUG_INFO window name modifier. You'll need to change the mode in the application you are serving - no way around that in Angular2.

I'm not sure if that was the original issue from @ravitej-klair or not, but in either case, I'm closing this as infeasible to change for now. See instead clean new issue: https://github.com/angular/protractor/issues/3174

juliemr avatar Apr 26 '16 18:04 juliemr