1

The issue I'm having is that Locomotive is not being terminated after each Cucumber scenario is run. Then I'm being left with orphaned Selenium processes, e.g.:

501 75709     1   0  1:29PM ??         0:00.05 /Users/rich/IdeaProjects/selenium/chromedriver.mac --port=45715
501 75720     1   0  1:29PM ??         0:00.04 /Users/rich/IdeaProjects/selenium/chromedriver.mac --port=12004

This is my PicoContainer setup class, so that it will inject an instance of Locomotive into each Cucumber scenario (which it does):

    public class CustomPicoFactory extends PicoFactory {

    public CustomPicoFactory() {
        addClass(Locomotive.class);
    } 
}

This entry is in my cucumber.properties file:

cucumber.api.java.ObjectFactory = CustomPicoFactory

Here is an example step definition class:

public class BorrowerSteps {

    Locomotive locomotive;

    public BorrowerSteps(Locomotive locomotive) {
        this.locomotive = locomotive;
    }
}

Is there some sort of cleanup method I can call after each Scenario is run? Or a better way of doing what I'm trying to achieve?

risteard
  • 47
  • 5
  • why are you injecting Locomotive instances? Shouldn't your test classes be extending Locomotive, like in the [examples](http://conductor.ddavison.io/examples/)? Maybe if you'd post a reproducable example of your test/step class it would make sense. – eis Dec 17 '15 at 18:59
  • 1
    I'm injecting instances of Locomotive so that I can share the same instance between Cucumber steps in a scenario. If I extended Locomotive on each Cucumber step definition class, I'd have multiple instances of locomotive per scenario. I'll get to creating an example, so that things are clearer. – risteard Dec 17 '15 at 19:13

1 Answers1

0

the chromedriver is being left open because upon instantiation of a Locomotive object, the chromedriver is created.

It isn't killed until driver.quit() is called. In order to do that, you can call locomotive.teardown() or locomotive.driver.quit()

ddavison
  • 28,221
  • 15
  • 85
  • 110