2

Most of the questions I've read so far only deal with trying to debug the unit tests / e2e tests when running Protractor / vscode (or rather how to make the breakpoints work in vscode)

In my case, I'm able to place breakpoints in my e2e tests and vscode have no issues with them, but the problem, once I'm inside the it() function, I have no clue how to access/inspect my components

I know e2e tests are not about components, but in this case, I was able to find a nasty bug that only e2e tests were able to catch, and I really need to inspect component variables to see what's going on

    it('should do something with ProductComponent', () =>
{
    // Code...
        
    // Once I'm here, how can I inspect ProductComponent anyway??
}

where, for example, ProductComponent looks like this:

@Component({
    selector   : 'app-product',
    templateUrl: './product.component.html',
    styleUrls  : ['./product.component.css']
})
export class ProductComponent
{
    productId: number;
    productSKU: number;
    
    // ...
}

1 Answer 1

1

Try browser.pause() or browser.explore() methods. I think that explore fits more into your needs.

http://www.protractortest.org/#/api?view=ProtractorBrowser.prototype.pause http://www.protractortest.org/#/api?view=ProtractorBrowser.prototype.explore

import {browser} from 'protractor';

describe('suite', () => {
    it('test',() => {
        browser.pause();
        browser.explore();
    });
}); 
Sign up to request clarification or add additional context in comments.

8 Comments

Thanks Maciej, but I'm afraid I don't see how this would help me inspect the component(s)
I meant inspect component variable values, so as per the example I mentioned in my question, how to get the value of variable productId (which belongs to ProductComponent)
Any update on that? Is browser.explore() that what you were looking for?
I'm still learning about the .explore(), I mean OK - it allows to pause and use list() to query the DOM, but so far I couldn't find a way to use it to inspect the components (some of my components have variables that are NOT rendered in the DOM, so DOM query won't help much in my case)
Great. I am happy, that my answer was at least a bit helpful :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.