Browser Back Button using protractor or javascript

2019-03-22 17:27发布

问题:

I am writing an automated test for the browser back button on logout of an angular application using a combination of protractor and cucumberjs.

When trying to use the command history.back() I get the following error:

 ReferenceError: history is not defined
        at World.<anonymous> (/Users/&&&&&/&&&&&/features/step_definitions/browsers.js:62:16)

This points to where I'm calling the history.back(); function.

How do I fix this, or correctly implement a browser back function using cucumber js?

回答1:

In your protractor test:

browser.navigate().back();