You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I attach EventFiringWebDriver to the webdriver.
EventFiringWebDriver is used to listen to the events in the browserdriver.
It is a wrapper over the webdriver initited as below
EventFiringWebDriver efwd = new EventFiringWebDriver(ie11);
efwd.register(new CustomEventLogger());
How can I get the efwd when i access the driver using $.driver().get()
Oh, hey, sorry for the delay. I wanted to test before answering.
And I actually found out it is a bit too complicated for you to do it, but here's one way:
// create a LOCAL driverSeleniumQueryBrowserchrome = newSeleniumQueryBrowser();
chrome.$.driver().useChrome().headless().autoDriverDownload().autoQuitDriver();
// get the driverWebDrivermyDriver = chrome.$.driver().get();
// wrap itEventFiringWebDriverefwd = newEventFiringWebDriver(myDriver);
// register the listener (can be done later as well)efwd.register(newCustomEventLogger());
// configure seleniumQuery GLOBAL to use the "wrapped" version as driver$.driver().use(efwd);
// now proceed as usual$.url("http://www.google.com");
It should work if you have immediate needs.
But I'd like to make it easier for us to use it. I can implement it in the API. If you have any suggestions I'd be glad to hear them.
Thanks for the reply. I tried this option. It does not work, apparently because $.driver().use(efwd) destroys existing instance of webdriver, so $.url("http://www.google.com"); failed.
For now I have extended the driverBuilder.
`
public class ChromeDriverBuilder extends
io.github.seleniumquery.browser.driver.builders.ChromeDriverBuilder {
That's a great suggestion, thank you! I will try to implement it this weekend, ok? I will reference this issue in the commit. There's no pressing need for you to write a PR, but if you do, feel free and I'd gladly accept it!
Activity
acdcjunior commentedon Apr 20, 2018
Oh, hey, sorry for the delay. I wanted to test before answering.
And I actually found out it is a bit too complicated for you to do it, but here's one way:
It should work if you have immediate needs.
But I'd like to make it easier for us to use it. I can implement it in the API. If you have any suggestions I'd be glad to hear them.
gmkumar2005 commentedon Apr 25, 2018
Thanks for the reply. I tried this option. It does not work, apparently because$.driver().use(efwd) destroys existing instance of webdriver, so $ .url("http://www.google.com"); failed.
For now I have extended the driverBuilder.
`
public class ChromeDriverBuilder extends
io.github.seleniumquery.browser.driver.builders.ChromeDriverBuilder {
private WebDriverEventListener webDriverEventListener;
@OverRide
protected WebDriver build() {
}
public io.github.seleniumquery.browser.driver.builders.ChromeDriverBuilder withEventListener(
WebDriverEventListener eventListener) {
this.webDriverEventListener = eventListener;
return this;
}
}
`
The usage is
ChromeDriverBuilder driverBuilder = new ChromeDriverBuilder(); driverBuilder.headless(); driverBuilder.autoDriverDownload(); driverBuilder.autoQuitDriver(); driverBuilder.withEventListener(new SeleniumEventLogger()); driver = driverBuilder.build(); $.driver().use(driver);It would be nice if you can add this in all the driverbuilders. I could send a PR but right now I am busy.
acdcjunior commentedon Apr 25, 2018
That's a great suggestion, thank you! I will try to implement it this weekend, ok? I will reference this issue in the commit. There's no pressing need for you to write a PR, but if you do, feel free and I'd gladly accept it!
acdcjunior commentedon May 3, 2018
JSYK, 0.19.0 has been released, containing your patch: https://github.com/seleniumQuery/seleniumQuery/releases/tag/0.19.0
Thanks again!