The Cucumber + Selenium boilerplate problem Every Cucumber + Selenium project in Java starts the same way. Before you write a single step, you write the infrastructure: public class Hooks { private WebDriver driver ; @Before public void setUp () { WebDriverManager . chromedriver (). setup (); ChromeOptions options = new ChromeOptions (); driver . manage (). timeouts (). implicitlyWait ( Duration . ofSeconds ( 10 )); driver = new ChromeDriver ( options ); DriverHolder . set ( driver ); } @After public void tearDown ( Scenario scenario ) { if ( scenario . isFailed ()) { byte [] screenshot = (( TakesScreenshot ) driver ). getScreenshotAs ( OutputType . BYTES ); scenario . attach ( screenshot , "image/png" , "Failure screenshot" ); } if ( driver != null ) driver . quit (); DriverHolder . remove (); } } Enter fullscreen mode Exit fullscreen mode Then you wire a ThreadLocal for parallel safety. Then you figure out how to get it into step definitions. Then you add a static helper class.…