[JVM][PicoContainer] 'org.openqa.selenium.WebDriver' is not instantiable

1,326 views
Skip to first unread message

Richard Paul

unread,
Nov 8, 2012, 10:07:02 PM11/8/12
to cu...@googlegroups.com
I've been following a similar pattern to https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-webbit-websockets-selenium for sharing the WebDriver instance across scenarios (SharedDriver).
This pattern means that a 'SharedDriver' instance is injected into steps defs etc as seen in https://github.com/cucumber/cucumber-jvm/blob/master/examples/java-webbit-websockets-selenium/src/test/java/cucumber/examples/java/websockets/NavigationStepdefs.java

I'd like my step defs (and other classes) to depend on WebDriver, not my specific subclass SharedDriver to allow code reuse between teams etc, however changing the constructor from:

public NavigationStepdefs(SharedDriver webDriver) {
  this.webDriver = webDriver;
}

to

public NavigationStepdefs(WebDriver webDriver) {
  this.webDriver = webDriver;
}

results in the following exception:
org.picocontainer.injectors.AbstractInjector$NotConcreteRegistrationException: Bad Access: 'org.openqa.selenium.WebDriver' is not instantiable
    at org.picocontainer.injectors.AbstractInjector.checkConcrete(AbstractInjector.java:86)
    at org.picocontainer.injectors.AbstractInjector.<init>(AbstractInjector.java:67)
    at org.picocontainer.injectors.SingleMemberInjector.<init>(SingleMemberInjector.java:43)
    at org.picocontainer.injectors.ConstructorInjector.<init>(ConstructorInjector.java:104)

It seem that PicoContainer doesn't recognise SharedDriver as a type of WebDriver, even though it extends EventFiringWebDriver which in turn implements WebDriver.

Would someone point me in the right direction with Cucumber's PicoContainer integration?

aslak hellesoy

unread,
Nov 9, 2012, 2:03:45 AM11/9/12
to Cucumber Users
On Fri, Nov 9, 2012 at 3:07 AM, Richard Paul <richard...@gmail.com> wrote:
I've been following a similar pattern to https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-webbit-websockets-selenium for sharing the WebDriver instance across scenarios (SharedDriver).
This pattern means that a 'SharedDriver' instance is injected into steps defs etc as seen in https://github.com/cucumber/cucumber-jvm/blob/master/examples/java-webbit-websockets-selenium/src/test/java/cucumber/examples/java/websockets/NavigationStepdefs.java

I'd like my step defs (and other classes) to depend on WebDriver, not my specific subclass SharedDriver to allow code reuse between teams etc, however changing the constructor from:

public NavigationStepdefs(SharedDriver webDriver) {
  this.webDriver = webDriver;
}

to

public NavigationStepdefs(WebDriver webDriver) {
  this.webDriver = webDriver;
}

results in the following exception:
org.picocontainer.injectors.AbstractInjector$NotConcreteRegistrationException: Bad Access: 'org.openqa.selenium.WebDriver' is not instantiable
    at org.picocontainer.injectors.AbstractInjector.checkConcrete(AbstractInjector.java:86)
    at org.picocontainer.injectors.AbstractInjector.<init>(AbstractInjector.java:67)
    at org.picocontainer.injectors.SingleMemberInjector.<init>(SingleMemberInjector.java:43)
    at org.picocontainer.injectors.ConstructorInjector.<init>(ConstructorInjector.java:104)

It seem that PicoContainer doesn't recognise SharedDriver as a type of WebDriver,

Not quite. PicoContainer doesn't even know that SharedDriver exists unless it sees it in one of the constructors. PicoContainer does provide an API for registering classes explcitly: http://picocontainer.codehaus.org/javadoc/core/org/picocontainer/MutablePicoContainer.html#addComponent(java.lang.Object)

Unfortunately, PicoContainer isn't exposed to you until there is a fix for https://github.com/cucumber/cucumber-jvm/issues/330

Maybe one of the other DI containers that provide a different configuration mechanism can help you here.
 
even though it extends EventFiringWebDriver which in turn implements WebDriver.

Would someone point me in the right direction with Cucumber's PicoContainer integration?

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
 
 

Roberto Lo Giacco

unread,
Nov 9, 2012, 4:05:01 AM11/9/12
to cu...@googlegroups.com
You might want to give a try to smartunit (https://github.com/rlogiacco/SmartUnit) which provides a SharedWebDriver implementation: read the wiki for more info
Reply all
Reply to author
Forward
0 new messages