protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Browser freezes when fixture.debugElement is expected to be Null

Open egdraper opened this issue 9 years ago • 2 comments

I have a test that checks if a DOM element has been removed by an ngIf. When I grab the DOM element using: fixture.debugElement.query(By.css(".something")) the result is either null or a DOM element.

If the result is null, then the following test works fine. But, if the test result contains an element, it doesn't simply fail the test, it freezes up the debug browser.

The test looks like this:

var result = fixture.debugElement.query(By.css("#something")) expect(result).toBe(null) // same goes for .toBeFalsy(), .toEqual(null)

This is not a problem if you use document.getElementById("something") to get the element. So the issue seems to be only if you try to check if a fixture element is null when it is not.

egdraper avatar Jan 26 '17 15:01 egdraper

fixture.debugElement sounds like this should be filed against the angular project and not Protractor.

cnishina avatar Jan 30 '17 21:01 cnishina

You shouldn't use DebugElement with expect. https://medium.com/@martatatiana/poor-detective-angular2-browser-crash-and-debugelement-f0a651dbf33#.ckjomzy34

volodyad avatar Feb 23 '17 09:02 volodyad