我对任何类型的编程都是一个绝对的初学者,目前我正在为我参加的一门课程做期末项目.
然而,我被困在了我的一个台阶上.无论我做什么,我都会得到"未定义的步骤".现在,互联网将我指向黄瓜选项中的gulp ,但我确信我已经指定了包装,我所有的其他步骤都工作得很好,如果gulp 粘得不好,所有步骤都没有定义,就像我之前发现的那样.
所以,在我的情况下,这一个单一的步骤一直是不确定的,我就是想不出来.
以下是我的步骤定义
package Mystore;
import io.cucumber.datatable.DataTable;
import io.cucumber.datatable.UndefinedDataTableTypeException;
import io.cucumber.java.en.And;
import io.cucumber.java.AfterAll;
import io.cucumber.java.BeforeAll;
import io.cucumber.java.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class StepDefinition {
private static WebDriver driver;
@Before
public void setup() {
driver = new ChromeDriver();
}
//@AfterAll
//public static void teardown() {
// driver.quit();
//}
@Given("User is logged in")
public void user_is_logged_in() {
driver.get("https://mystore-testlab.coderslab.pl/index.php");
WebElement element;
element = driver.findElement(By.className("user-info"));
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
element.click();
WebElement email = driver.findElement(By.id("field-email"));
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
email.click();
email.sendKeys("gkqvuzdwzxoltwlnij@ckptr.com");
driver.findElement(By.id("field-password")).sendKeys("qwerty1");
WebElement sign = driver.findElement(By.id("submit-login"));
sign.click();
}
@When("add address is clicked")
public void add_address_is_clicked() {
WebElement address;
address = driver.findElement(By.xpath("//*[@id=\"footer_account_list\"]/li[4]/a"));
address.click();
WebElement clkaddress;
clkaddress = driver.findElement(By.xpath("//*[@id=\"content\"]/div[2]/a"));
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
clkaddress.click();
}
@Then("fill in credentials with <alias>")
public void fill_in_credentials_with(String alias){
driver.findElement(By.className("col-md-6")).sendKeys(alias);
//alias.sendKeys(Userdata.cell(1,1));
}
@And("submit and close the page")
public void ubmit_and_close_the_page() {
driver.quit();
}
}
我的特色
Feature: Create address on mystore
Scenario Outline: Test filling in address
Given User is logged in
When add address is clicked
Then fill in credentials with <alias>
And submit and close the page
Examples:
| alias | address | city | zip | country | phone |
| RWT | Lubelska | Warszawa | 01-999 | Poland | 498100234 |
我的 run 者
package Mystore;
import org.junit.runner.RunWith;
import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
//glue = {"helpers", "src.test.java.steps"},
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/Resources/Mystore/Userdata.feature",
glue = {"Mystore"},
snippets = CucumberOptions.SnippetType.CAMELCASE,
plugin = {"pretty"}
)
//format = {"pretty"})
public final class RunCucumberTest {
}
我的POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zaliczenie</groupId>
<artifactId>zaliczenie</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>4.13.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>22.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.0.0</version>
</dependency>
</dependencies>
</project>
误差率
io.cucumber.junit.UndefinedStepException: The step 'fill in credentials with RWT' is undefined.
You can implement this step using the snippet(s) below:
@Then("fill in credentials with RWT")
public void fillInCredentialsWithRWT() {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
我已经看过gulp 了,应该没问题.我确实确保了我的依赖项不会过时或彼此不兼容.我try 了几种不同的方法.
文件 struct 如下所示