【发布时间】:2021-01-20 10:08:10
【问题描述】:
当尝试使用运行器运行测试时,我为功能文件创建了一个测试。运行器已成功构建并完成,但没有任何反应。
功能文件:
Feature: Login to Queries
#Login in Chrome
Scenario: Login using Chrome
Given I open Chrome
When I browse to Queries
Then I login to Queries using "pcy1" and "123"£"
步骤定义(该类扩展基类):
public class login extends base {
@Given("^I open Chrome$")
public void iOpenChrome() throws Throwable {
driver = initializeDriver();
throw new PendingException();
}
@When("^I browse to Queries$")
public void iBrowseToQueries() {
driver.get("https://atesting321.test/");
throw new PendingException();
}
@Then("^I login to Queries using \"([^\"]*)\" and \"([^\"]*)\"£\"$")
public void iLoginToQueriesUsingAnd£(String username, String password) throws Throwable {
driver.findElement(By.id("UserName")).sendKeys(username);
driver.findElement(By.id("Password")).sendKeys(password);
driver.findElement(By.id("btnLogin")).click();
throw new PendingException();
}
跑步者
@RunWith(Cucumber.class)
@CucumberOptions(
features= "src/test/java/features/login",
glue= "stepDefinitions")
public class RunTest {
public static void main (String[] args)
{}
基类(用作全局变量)
public class base {
public WebDriver driver;
public Properties prop;
public ChromeOptions coptions;
public WebDriver initializeDriver() throws IOException
{
prop= new Properties();
String browserName= "chrome";
System.out.println(browserName);
String pathToDriver = "";
if(browserName.equals("chrome"))
{
pathToDriver = "C:\\Repositories\\automationProject\\webDrivers\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", pathToDriver);
coptions.addArguments("disable-infobars");
coptions.addArguments("--start-maximized");
driver= new ChromeDriver(coptions);
//execute in chrome driver
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
return driver;
}
当我运行 RunTest java 文件时,我得到以下结果:
进程以退出代码 0 结束
【问题讨论】:
-
您使用什么 JUnit 版本?请务必仔细阅读文档,请参阅此处的 JUnit 部分 cucumber.io/docs/cucumber/api
-
另外描述一下你期望得到什么结果?
标签: java selenium testing intellij-idea cucumber