I have following jar files added to my project :
- gherkin 2.12
- cucumber-junit 1.2.5
- cucumber-java 1.2.5
- cucumber core 1.2.5
- cucumber jvm-deps 1.0.5
- cobetura 2.1.1
- mockito all 1.9.1
- cucumber-reporting 3.13
I am getting an error when I try to run test runner class:
cucumber.runtime.CucumberException: Failed to instantiate class stepDefinition.Test_steps
Test Runner Class:
package CucumberTest;
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
import cucumber.api.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "Feature"
,glue={"stepDefinition"}
)
public class TestRunner {
}
Test_steps Class
package stepDefinition;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import PageObject.LoginVariables;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class Test_steps {
private static WebDriver driver = null;
WebDriverWait wait = new WebDriverWait(driver, 60);
@Given("^User is on Homepage$")
public void user_is_on_Homepage() throws Throwable {
// Write code here that turns the phrase above into concrete actions
driver = new ChromeDriver();
System.setProperty("webdriver.chrome.driver", "C:\Selenium\chromedriver.exe");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://test.salesforce.com");
throw new PendingException();
}
@When("^User Enters userId and Password$")
public void user_Enters_userId_and_Password() throws Throwable {
// Write code here that turns the phrase above into concrete actions
wait.until(ExpectedConditions
.visibilityOfElementLocated(By.xpath(LoginVariables.login_xpath)))
.sendKeys("[email protected]");
wait.until(ExpectedConditions
.visibilityOfElementLocated(By.xpath(LoginVariables.password_xpath)))
.sendKeys("password");
wait.until(ExpectedConditions
.visibilityOfElementLocated(By.xpath(LoginVariables.login_xpath))).click();
throw new PendingException();
}
@Then("^User is able to login sucessfully in salesorce$")
public void user_is_able_to_login_sucessfully_in_salesorce() throws Throwable {
// Write code here that turns the phrase above into concrete actions
System.out.println("User Login Sucessful");
throw new PendingException();
}
}
Folder Structure:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…