1
Why is not my console printing anything when I am trying to run the event listener class with the Selenium Webdriver?

Solved 2 Answers 37 Views Selenium

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());

}

}

2 Answers

0
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.

answered Apr 10, 2016 by stbadmin (4,970 points)
selected Mar 7 by stbadmin
0

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.

answered Apr 10, 2016 by stbadmin (4,970 points)
...