0

Hello every body i am working on a project in which have to implement cucumber with selenium when i run my code following error message is shown I have JDK 7 installed and i am using Jars in image

enter image description here

java.lang.NoSuchMethodError: cucumber.runtime.RuntimeOptions.<init>(Ljava/util/Properties;[Ljava/lang/String;)V
    at cucumber.runtime.junit.RuntimeOptionsFactory.create(RuntimeOptionsFactory.java:32)
    at cucumber.api.junit.Cucumber.<init>(Cucumber.java:56)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Feature is : Feature: Check addition in Google calculator In order to verify that google calculator work correctly As a user of google I should be able to get correct addition result

Scenario: Addition Given I open google When I enter "2+2" in search textbox Then I should get result as "4"

**Cucumber Steps Class IS :** 


    import java.util.concurrent.TimeUnit;

    import org.junit.Assert;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.By;

        import cucumber.api.java.After;
        import cucumber.api.java.Before;
        import cucumber.api.java.en.Given;
        import cucumber.api.java.en.Then;
        import cucumber.api.java.en.When;

        public class googleCalcStepDefinition {


            protected WebDriver driver;

             @Before
                public void setup() {
                    driver = new FirefoxDriver();
            }

            @Given("^I open google$")
            public void I_open_google() {
                //Set implicit wait of 10 seconds and launch google
                driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
                driver.get("https://www.google.co.in");
            }

            @When("^I enter \"([^\"]*)\" in search textbox$")
            public void I_enter_in_search_textbox(String additionTerms) {
                //Write term in google textbox
                WebElement googleTextBox = driver.findElement(By.id("gbqfq"));
                googleTextBox.sendKeys(additionTerms);

                //Click on searchButton
                WebElement searchButton = driver.findElement(By.id("gbqfb"));
                searchButton.click();
            }

            @Then("^I should get result as \"([^\"]*)\"$")
            public void I_should_get_correct_result(String expectedResult) {
                //Get result from calculator
                WebElement calculatorTextBox = driver.findElement(By.id("cwos"));
                String result = calculatorTextBox.getText();

                //Verify that result of 2+2 is 4
                Assert.assertEquals(result, expectedResult);

                driver.close();
            }

             @After
                public void closeBrowser() {
                    driver.quit();
             }

        }


        **Junit Runner Class is :** 

            import org.junit.runner.RunWith;

            import cucumber.api.junit.Cucumber;

            import cucumber.api.CucumberOptions;;

            @RunWith(Cucumber.class)


 @CucumberOptions(features = {"src/"},glue = {"src/googleCalcStepDefinition.java"})
            public class googleCalcTest {
            }
2
  • Looks like you have incompatible jar files in your classpath Commented May 20, 2015 at 6:03
  • can you please tell me which jars then i must use ? Commented May 20, 2015 at 7:09

2 Answers 2

3

Fixed This issue just by installing JDK8 64 bit and Eclipse LUNA 64 bit and then using following jars enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

Looks like the cucumber.runtime.RuntimeOptions has no constructor which accepts parameters Properties and String. Cucumber libraries you are using do not support this.

Try using something like below.

    import org.junit.runner.RunWith;

    import cucumber.api.junit.Cucumber;

    import cucumber.api.CucumberOptions;;

    @RunWith(Cucumber.class)
    @CucumberOptions(
      features = "<path to feature file>",
      glue = "src/googleCalcStepDefinition.java"
    )
    public class googleCalcTest {
    }

7 Comments

edited my answer, there was a bracket missing. Could you try?
i added them my self still same error message shown
Btw, feautues should have value as ''path to feature file" , I see you are giving a java file name. Feature files generally have extension of .feature
Can you Please share with me any working test project which is working fine on your machine so that i can verify its not JAR compliance issue ?
i made that change too and edited the code renamed feature as features = {"src/"}
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.