I want to use Event Listeners in Page Object Pattern following Page-factory

310 views
Skip to first unread message

Biswajit Samal

unread,
May 28, 2015, 7:40:24 AM5/28/15
to seleniu...@googlegroups.com

I have followed Google and found ample of solution for how to use "Event Listeners", but all are in the same class. I want to use this beautiful approach in page-factory . Please guide me.

Afzal

unread,
May 28, 2015, 3:16:04 PM5/28/15
to seleniu...@googlegroups.com

Biswajit Samal

unread,
May 28, 2015, 8:37:20 PM5/28/15
to seleniu...@googlegroups.com
Hello Afzal,

Thanks for the reply, I have already followed this tutorial and designed the same, but I want to implement the beautiful event-listener with my page object pattern followed by page-factory.

this is  what I want. If possible I will share the sample code to you.

Krishnan Mahadevan

unread,
May 28, 2015, 10:59:37 PM5/28/15
to Selenium Users
Biswajit,

I like your usage "Beautiful event listeners" :)
Jokes apart, you would need to tell us what are you referring to when you say "Event Listeners" ? Please feel free to share more information around this.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/3223970e-200b-42aa-8620-06982e9f8350%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Biswajit Samal

unread,
May 29, 2015, 4:20:41 AM5/29/15
to seleniu...@googlegroups.com
Respected Sir,

I am sharing the code, what exactly I want to achieve with Selenium Event Listener

I have followed this blog and really love this approach for better debugging and tried it.

Now I want to implement this with the page object and page factory pattern in selenium.

My code :
PAGES:

public class Pages {
public WebDriver driver;
public Pages(WebDriver driver){
this.driver =  driver;
}
@FindBy(how=How.NAME,using="q")
public static WebElement searchTextBox;
@FindBy(how=How.NAME,using="btnG")
    public static WebElement clickSearchButton;
}


BASECLASS:

public class SelTestCase {
public WebDriver driver;
@BeforeTest
public void setUp(){
driver = new FirefoxDriver();
}
@AfterTest
public void tearDown(){
driver.close();
driver.quit();
}


ACTION:

public class Action extends SelTestCase{
public void searchItem(){
EventFiringWebDriver event = new EventFiringWebDriver(driver);
WebDriverListerners eventListener = new WebDriverListerners();
event.register(eventListener);
event._________________________
}

In the above example the gray highlighted filed is showing error, I want to call the event in the Action class then in to @Test. Which I do not understand how to do.
Please guide me. I want to implement this approach in my project.

Please help me sir.

Krishnan Mahadevan

unread,
May 29, 2015, 4:47:14 AM5/29/15
to Selenium Users
Biswajit

EventFiringWebDriver will not work with events that arise from the Actions class. So its not a complete solution.


But the catch with the above post is that it cannot be used to work with FirefoxDriver, ChromeDriver etc., but it would need to be worked only with RemoteWebDriver.





Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

Biswajit Samal

unread,
May 29, 2015, 6:56:56 AM5/29/15
to seleniu...@googlegroups.com
Respected Sir,

This approach is also good, But I want to use this in page-factory . 
Please guide me , I am still looking for a solution.

Biswajit Samal

unread,
Jun 3, 2015, 1:46:08 AM6/3/15
to seleniu...@googlegroups.com
After searching , I am going to implement Log4j  for this, which is a nice tool for better debugging.

virendra chaudhary

unread,
Jun 30, 2015, 5:30:01 AM6/30/15
to seleniu...@googlegroups.com
Hi Biswajit,

I find there is no limitation in using WebDriverEventListener with pagefactory. Please tell me error you are getting and where you are initializing WebElements of pages.
Reply all
Reply to author
Forward
0 new messages