Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:14:16+00:00 2026-06-14T20:14:16+00:00

This is driving me nuts. I’m running a test framework using cucumber-jvm and trying

  • 0

This is driving me nuts. I’m running a test framework using cucumber-jvm and trying to get it to take screenshots.
I have looked at the java-webbit-websockets-selenium example that’s provided and have implemented the same method of calling my webdriver using the SharedDriver module.
For some reason, my @Before and @After methods are not being called (I’ve put print statements in there). Can anyone shed any light?

SharedDriver:

package com.connectors;

import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.Scenario;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.support.events.EventFiringWebDriver;

import java.util.concurrent.TimeUnit;


public class SharedDriver extends EventFiringWebDriver {




    private static final WebDriver REAL_DRIVER = new FirefoxDriver();

        private static final Thread CLOSE_THREAD = new Thread() {
            @Override
            public void run() {
                REAL_DRIVER.close();
            }
        };

        static {
            Runtime.getRuntime().addShutdownHook(CLOSE_THREAD);
        }

        public SharedDriver() {
            super(REAL_DRIVER);
            REAL_DRIVER.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
            REAL_DRIVER.manage().window().setSize(new Dimension(1200,800));
            System.err.println("DRIVER");
        }

        @Override
        public void close() {
            if(Thread.currentThread() != CLOSE_THREAD) {
                throw new UnsupportedOperationException("You shouldn't close this WebDriver. It's shared and will close when the JVM exits.");
            }
            super.close();
        }

        @Before()
        public void deleteAllCookies() {
            manage().deleteAllCookies();
            System.err.println("BEFORE");
        }

        @After
        public void embedScreenshot(Scenario scenario) {
            System.err.println("AFTER");
            try {
                byte[] screenshot = getScreenshotAs(OutputType.BYTES);
                scenario.embed(screenshot, "image/png");
            } catch (WebDriverException somePlatformsDontSupportScreenshots) {
                System.err.println(somePlatformsDontSupportScreenshots.getMessage());
            }
        }


    }

Step file:

package com.tests;

import com.connectors.BrowserDriverHelper;
import com.connectors.SharedDriver;
import com.connectors.FunctionLibrary;

import cucumber.api.Scenario;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import cucumber.runtime.PendingException;
import org.openqa.selenium.*;


import java.io.File;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.support.events.EventFiringWebDriver;

/**
 * Created with IntelliJ IDEA.
 * User: stuartalexander
 * Date: 23/11/12
 * Time: 15:18
 * To change this template use File | Settings | File Templates.
 */
public class addComponentsST {
    String reportName;
    String baseUrl = BrowserDriverHelper.getBaseUrl();
    private final WebDriver driver;

    public addComponentsST(SharedDriver driver){
        this.driver = driver;
        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    }

    @Given("^I have navigated to the \"([^\"]*)\" of a \"([^\"]*)\"$")
    public void I_have_navigated_to_the_of_a(String arg1, String arg2) throws Throwable {
        // Express the Regexp above with the code you wish you had
        assertEquals(1,2);
        throw new PendingException();
    }

CukeRunner:

package com.tests;

import org.junit.runner.RunWith;

import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@Cucumber.Options(tags = {"@wip"}, format = { "pretty","html:target/cucumber","json:c:/program files (x86)/jenkins/jobs/cucumber tests/workspace/target/cucumber.json" }, features = "src/resources/com/features")
public class RunCukesIT {
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:14:17+00:00Added an answer on June 14, 2026 at 8:14 pm

    Put SharedDriver in the same package as RunCukesIT, i.e. com.tests.

    When using the JUnit runner, the glue becomes the unit test package (here com.tests), and this is where cucumber-jvm will “scan” the classes for annotations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is driving me nuts! I have a test instance of Wordpress installed on
This is driving me nuts. I can't seem to get the data template within
Ok, this is driving me nuts... I'm trying to rewrite my urls like this:
This is driving me nuts, I can't see the problem. Using jQuery (I'm stuck
This is driving me nuts, I have been through every article I have seen
This is driving me nuts. I am trying to set a background image to
This is driving me nuts. http://www.cssdrive.com/index.php/examples/exampleitem/focus_pseudo_class This is an example of using the hover
This is driving me nuts. I have a working text based application. It has
This is driving me nuts. I registered a DLL (COM) using regsvr32 blabla.dll In
This is driving me nuts. I have the following code that, when a button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.