简体   繁体   中英

How to debug failed test steps in protractor

How to debug failed test steps in protractor?

Following is my test case.

it('Testcase-TC_BY_09 , Case 2: User Selects NO option', function() {
   //Execution Steps 
  Login();//Calling Login Function
//options Click 
    //book_typeValidation();
    book_type.click();
    expect(Nextbtn.isEnabled()).toBe(true);
    Nextbtn.click();`enter code here`

    //True_pages _Validation();
    True_pagesoption.click();
    expect(Nextbtn.isEnabled()).toBe(true);
    Nextbtn.click();

    expect(Nextbtn.isEnabled()).toBe(true);
    Nextbtn.click();

    expect(Nextbtn.isEnabled()).toBe(true);
    Nextbtn.click();
    Poles_Nooption.click();    
    expect(Nextbtn.isEnabled()).toBe(true);     
    Nextbtn.click();
      });

Lets say this test case have 10 test steps.When we execute this test case,if it fails in 5th step how to find tat failed step in protractor?

Right now how it is working is it will show the test case failed in console.But it is not showing which steps it has failed?

Please give your suggestion to find out failed step in protractor.

Thanks in advance.

First of all, you want your e2e tests provide you with a meaningful explicit information about the failure, on which line it failed, on which step, what could have caused it etc - minimizing the time to understand and research the reasons for the failure. And, it's also important to see every test you write fail so that you can observe if it fails in a reasonably "clear" way.

Organize your test case into multiple steps having each step defined in a separate function:

it('Testcase-TC_BY_09 , Case 2: User Selects NO option', function() {
    Login();

    selectBookType();
    next();

    selectPagesOption();
    next();

    next();
    next();

    selectPolesNoOption();
    next();
});

And, you can provide meaningful error messages using jasmine built-in mechanisms:

expect(Nextbtn.isEnabled()).toBe(true, "Next is disabled after clicking option");  

I would also recommend using protractor-jasmine2-screenshot-reporter jasmine reporter which would provide you with screenshots of the browser window during the test run, or on test failures.

Also, services like BrowserStack and Sauce Labs provide you with visual logs and video sessions of a test run which, I personally find quite useful in debugging.

As for debugging, there is a relevant documentation page describing your options:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM