Listening for browser back-navigation

The browser back-navigation event, as we have already seen, gets invoked when we use the driver.navigation().back() method. The browser goes back one level in its history. Just like all the other events, this event is associated with two methods:

public void beforeNavigateBack(WebDriver driver)

The preceding method is invoked before the browser takes you back in its history. The WebDriver that invoked this event is passed as a parameter to this method:

public void afterNavigateBack(WebDriver driver)

Just as in all the after <<event>> methods, the preceding method is invoked when the navigate-back action is triggered. The preceding two methods will be invoked irrespective of the navigation of the browser; ...

Get Selenium WebDriver 3 Practical Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.