黄瓜没有找到步骤文件“用片段实现缺少的步骤”

时间:2017-06-30 11:02:02

标签: selenium-webdriver cucumber-java cucumber-serenity

我设计了我的FW,我在包中准确放置了跑步者和步骤文件。但是我无法运行TC,它表示虽然步骤已经定义,但测试暂挂。

PFA我的项目结构。 enter image description here

我的步骤文件:

package com.reThink.steps;

import net.thucydides.core.annotations.Steps;

import com.reThink.helper.LoginHelper;
import com.reThink.util.CBTestProperties;
import com.reThink.util.Constants;
import com.reThink.util.Log;

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

public class LoginSteps {

@Steps
LoginHelper loginHelper;

private String username = null;
private String password = null;

/**
 * Method to navigate to login page
 * 
 * @param
 * @return
 */
@Given("^I am on the reThink Login page$")
public void givenIamonthehomepage() throws Exception {
    loginHelper.openLoginPage();
}

/**
 * Method to login as a Admin user
 * 
 * @param
 * @return
 */
@When("^I login as an Admin user$")
public void loginWithAdminUser() throws Exception {
    loginHelper.openLoginPage();
    username = CBTestProperties.Instance
            .getTestProperty(Constants.ADMINUSERNAME);
    password = CBTestProperties.Instance
            .getTestProperty(Constants.ADMINPASSWORD);
    loginHelper.loginToRethink(username, password);
}

/**
 * I should be login successfully
 * 
 * @param
 * @return
 */
@Then("^I should be logged in successfully$")
public void thenItShouldBeLoggedIn() throws Exception {
    // assertThat(homePageHelper.isLoginSuccessful(username));
    Log.info("Successfully logged in");
}

}

功能文件

@Logon_Admin_User
Scenario: Login to reThink with Admin User credentials 
Given I am on the reThink Login page
When I login as an Admin user 
Then I should be logged in successfully 

1 个答案:

答案 0 :(得分:1)

您在跑步者类的黄瓜选项中缺少胶水路径。请尝试以下操作。

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features="src/test/resources/features",tags="@Logon_Admin_user",glue = { "com.reThink.steps" })
public class TestRunnerSuite{}