Do you have questions ? We got the answers!

Ask a question:

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 41 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)

Top Contributors

  • 4970 pointsstbadmin

    34 questions 454 answers218 comments

  • 433 pointsSunilBhaskar

    41 questions 15 answers32 comments

  • 425 pointsMehedi

    36 questions 3 answers14 comments

  • 363 pointssumitkumarwatts

    0 questions 13 answers0 comments

  • 354 pointsSoft Tester

    43 questions 0 answers4 comments

  • 327 pointsKeeshaGolden

    0 questions 17 answers2 comments

  • 322 pointsVipul Sharma

    44 questions 0 answers24 comments

  • 310 pointsvysh.sharma

    25 questions 0 answers0 comments

  • 267 pointsOnkar_Nimje

    33 questions 15 answers15 comments

  • 258 pointsVanitha

    26 questions 0 answers6 comments

...