Project Structure-image我正在为我的Java项目编写一些黄瓜测试。当运行黄瓜类时,控制台中没有发生错误,但是按照步骤定义脚本,我已经赋予脚本调用浏览器的权限,因此,按照我的假设,黄瓜类不会调用步骤定义类或胶水。 您能否检查一下并让我知道为什么不调用它。
Code:
@RunWith(Cucumber.class)
@CucumberOptions(
features={"F:/Selinium/practise-cucumber/practise1/features/login.feature"},
glue={"F:/Selinium/practise-cucumber/practise1/src/Stepdefinition/loginmethod.java"})
public class Runcucumber {
}
Step Definition code:
public class loginmethod {
public WebDriver driver ;
@Given("^User is on Home Page$")
public void user_is_on_home_page() throws Throwable{
System.out.println("homepagre");
System.setProperty("webdriver.chrome.driver",
"F:/Selinium/practise-cucumber/practise1/driver/chromedriver1.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com/");
System.out.println("lUNCHED homepagre");
}
Browser should be invoked
答案 0 :(得分:0)
能否将您的Runcucumber
类名更改为RuncucumberTest
,然后重试。我发生了一次。
@RunWith(Cucumber.class)
@CucumberOptions(
features={"F:/Selinium/practise-cucumber/practise1/features/login.feature"},
glue={"F:/Selinium/practise-cucumber/practise1/src/Stepdefinition/loginmethod.java"})
public class RuncucumberTest {
}