power_settings_new

Here is the code.


*EventListener Class*
public class Register {

PSVM(String[] args) {

WebDriver driver = new FirefoxDriver();

EventFiringWebDriver EFWD = new EventFiringWebDriver(driver);

EventListener el = new EventListener();

EFWD.register(el);

driver.get("Google");

driver.get("facebook,com");

driver.navigate().back();

}


*MainClass*

public class EventListener extends AbstractWebDriverEventListener{

public void afterNavigateBack(WebDriver arg0) {

System.out.println("after navigate "+arg0.getCurrentUrl());

}

}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

2 Answers

by (171 points)
selected by
0 votes
 
Best answer

Also you should be using EFWD instead of driver.

 

ex.

public class Register {

PSVM(String[] args) {

WebDriver driver = new FirefoxDriver();

EventFiringWebDriver EFWD = new EventFiringWebDriver(driver);

EventListener el = new EventListener();

EFWD.register(el);

EFWD.get("Google");

EFWD.get("facebook,com");

EFWD.navigate().back();

}

hope it helps.

by (171 points)
0 votes

I guess you will need to add @Override above afterNavigateBack method.

 

 

public class EventListener extends AbstractWebDriverEventListener{

@Override

public void afterNavigateBack(WebDriver arg0) {

System.out.println("after navigate "+arg0.getCurrentUrl());

}

}

 

Let me know.

add
...