Getting error regarding pico container in cucumber framework | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos
10% May Month Discount Avail now

Selenium Training Forum

Getting error regarding pico container in cucumber framework

S
sumit kalra Post on 13/03/2019

Hi Ashish,

I have already added the pico container jar file in my maven based cucumber project.

Still I am getting the error "class com.qtpselenium.teststeps.loginTest doesn't have an empty constructor. If you need DI, put cucumber-picocontainer on the classpath"

screenshot attached.

below is the code of my loginTest.java

-------------------------------

public class loginTest {

WebConnector conn;

public loginTest(WebConnector conn)
{
this.conn=conn;
}



@Given("^I open (.*)$")
public void i_open(String browser)
{
System.out.println("I open-"+conn.name);
/*
if(browser.equals("firefox"))
driver=new FirefoxDriver();
else if(browser.equals("chrome"))
driver=new ChromeDriver();
*/
}

@And("^I navigate to (.*)$")
public void i_navigate(String browser)
{
System.out.println("i navigate to"+browser);
}



@And("^I type username as (.*) in (.*)$")
public void i_type_username(String username,String usernamefield)
{
System.out.println("I type username as username in usernamefield");
}

@And("^I type password as (.*) in (.*)$")
public void i_type_password(String password,String passwordfield)
{
System.out.println("I type password as username in passwordfield");
}
@And("^I click on (.*)$")
public void i_click(String button)
{
System.out.println("I click on"+button);
}

}

 

D

Instructor

Demo Reply on 15/03/2019

You need to have the same version of all cucumber-* in your pom.xml

 

Reference: https://stackoverflow.com/questions/33999071/project-doesnt-recognize-cucumber-picocontainer-dependency