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?
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()