似乎没有获取数据 你能告诉我为什么会这样吗?
cucumber.api.PendingException: TODO: implement me at cucumber.runtime.junit.JUnitReporter.addFailure(JUnitReporter.java:150) at cucumber.runtime.junit.JUnitReporter.addFailureOrIgnoreStep(JUnitReporter.java:138) at cucumber.runtime.junit.JUnitReporter.result(JUnitReporter.java:98) at cucumber.runtime.Runtime.runStep(Runtime.java:282) at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44) at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39) at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44) at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at cucumber.runtime.junit.ExamplesRunner.run(ExamplesRunner.java:59) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at cucumber.runtime.junit.ScenarioOutlineRunner.run(ScenarioOutlineRunner.java:53) at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63) at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70) at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95) at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at cucumber.api.junit.Cucumber.run(Cucumber.java:100) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Feature: Test login to y4 web
#Scenario: Login with given account
#
#Given User is already login page
#When Title of login page is Login Y4
#Then User enter username "phanminh@y-4.jp" and User enrer password "test1234"
#Then User click on Login button
#Then User is on Homepage
Scenario Outline: Login with given account
Given User is already login page
When Title of login page is Login Y4
Then User enter username "<username>" and User enter password "<password>"
Then User click on Login button
Then User is on Homepage
Then Click on Home icon
Then Click on Search icon
Then Select user "<user>"
Then Select start date <start_year> <start_month> <start_date>
Then Select end date <end_year> <end_month> <end_date>
Then Click on search
Then Download excel file
Then Validate Download excel file
Then Close the browser
Examples:
|username|password|user|start_year|start_month|start_date|end_year|end_month|end_date|
|phanminh@y-4.jp|test1234|Yukinao Ajima|2019|01|01|2019|07|25|
|chiptest025@gmail.com|12345678|Huu Nguyen|2019|08|01|2019|08|25|
Feature: report select users y4 web
Scenario: report select users with given account
Given User is already login page
When Title of login page is Login Y4
Then User enter username "phanminh@y-4.jp" and User enrer password "test1234"
Then User click on Login button
Then User is on Homepage
Then Select following users
|minhphan116@gmail.com.vn|
|chipbuuu@gmail.com|
|yukinaoajima@gmail.com|
|nvhuu.grandm@gmail.com|
|stb.0201@gmail.com|
Then Click next
Then Select start date
|2019|01|01|
Then Select end date
|2019|08|26|
Then Click Search to download
package stepDefinition;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import cucumber.api.DataTable;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import junit.framework.Assert;
public class LoginStepDefinition {
WebDriver driver;
String downloadPath = "/Users/DELL/Downloads/";
@Given("^User is already login page$")
public void user_already_on_login() {
System.setProperty("webdriver.chrome.driver", "/Users/DELL/chromedriver/chromedriver.exe");
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("profile.default_content_setting_values.automatic_downloads", 1);
chromePrefs.put("download.default_directory", System.getProperty(downloadPath));
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
driver = new ChromeDriver(options);
driver.get("https://y4.genkimiru.jp/");
}
@When("^Title of login page is Login Y(\\d+)$")
public void title_of_login_page_is_Login_Y(int arg1) throws Throwable {
String title = driver.getTitle();
System.out.print(title);
Assert.assertEquals("Genkimiru & Vital Gain", title);
}
@Then("^User enter username \"([^\"]*)\" and User enrer password \"([^\"]*)\"$")
public void user_enter_username_and_User_enrer_password(String username, String password) throws Throwable {
// Write code here that turns the phrase above into concrete actions
driver.findElement(By.name("data[User][email]")).sendKeys(username);
driver.findElement(By.name("data[User][password]")).sendKeys(password);
}
@Then("^User click on Login button$")
public void user_click_on_Login_button() throws Throwable {
WebElement loginBtn = driver.findElement(By.xpath("//button[@type='submit']"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", loginBtn);
}
@Then("^User is on Homepage$")
public void user_is_on_Homepage() throws Throwable {
String homeTitle = driver.findElement(By.className("site_title")).getText();
Assert.assertEquals("ユーザー管理", homeTitle);
}
@Then("^Close the browser$")
public void close_the_browser() throws Throwable {
// Write code here that turns the phrase above into concrete actions
driver.quit();
}
@Then("^Click on Home icon$")
public void click_on_Home_icon() throws Throwable {
// Write code here that turns the phrase above into concrete actions
WebElement home = driver.findElement(By.xpath("//li[@id='menu_1']//a"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", home);
}
@Then("^Click on Search icon$")
public void click_on_Search_icon() throws Throwable {
WebElement home = driver.findElement(By.xpath("//li[@id='menu_5']//a"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", home);
}
@Then("^Select user \"([^\"]*)\"$")
public void select_user(String user) throws Throwable {
// Write code here that turns the phrase above into concrete actions
Select users = new Select(driver.findElement(By.name("data[Report][customer_id]")));
System.out.print("" + users.getAllSelectedOptions().size());
users.selectByVisibleText(user);
}
@Then("^Select start date (\\d+) (\\d+) (\\d+)$")
public void select_start_date(int year, int month, int date) throws Throwable {
// Write code here that turns the phrase above into concrete actions
String time = String.format("%d年%02d月%02d日", year, month, date);
WebElement dateButton = driver.findElement(By.id("ReportFrom"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", dateButton);
dateButton.clear();
// dateButton.click();
dateButton.sendKeys(Keys.DELETE);
dateButton.sendKeys(Keys.chord(Keys.COMMAND, "A"), time);
}
@Then("^Select end date (\\d+) (\\d+) (\\d+)$")
public void select_end_date(int year, int month, int date) throws Throwable {
String time = String.format("%d年%02d月%02d日", year, month, date);
WebElement dateButton = driver.findElement(By.id("ReportTo"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", dateButton);
dateButton.clear();
// dateButton.click();
dateButton.sendKeys(Keys.DELETE);
dateButton.sendKeys(Keys.chord(Keys.COMMAND, "A"), time);
}
@Then("^Click on search$")
public void click_on_search() throws Throwable {
// Write code here that turns the phrase above into concrete actions
WebElement search = driver.findElement(By.xpath("//button[@class='btn btn-danger pull-right']"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", search);
}
@Then("^Download excel file$")
public void download_excel_file() throws Throwable {
WebElement download = driver.findElement(By.xpath("//a[@class='btn btn-info pull-right']"));
String downloadURL = download.getAttribute("href");
driver.navigate().to(downloadURL);
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", download);
String filenameDownload = downloadURL.split("/")[downloadURL.split("/").length - 1];
System.out.println(filenameDownload);
// Validate excel file
boolean found = false;
long timeout = 20;// 20 seconds
long now = System.currentTimeMillis();
while (!found && ((System.currentTimeMillis() - now) / 1000) < timeout) {
Thread.sleep(1000);
File folder = new File(downloadPath);
File[] listOfFiles = folder.listFiles();
for (File listOfFile : listOfFiles) {
if (listOfFile.isFile()) {
String fileName = listOfFile.getName();
if (fileName.contains(filenameDownload)) {
found = true;
}
}
}
}
if (!found) {
Assert.assertTrue(found);
}
}
@Then("^Select following users$")
public void select_following_users(DataTable arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
// For automatic transformation, change DataTable to one of
// List<YourType>, List<List<E>>, List<Map<K,V>> or Map<K,V>.
// E,K,V must be a scalar (String, Integer, Date, enum etc)
List<String> users = arg1.asList(String.class);
WebElement table = driver.findElement(By.xpath("//table[@id='DataTables_Table_0']//tbody"));
List<WebElement> rows = table.findElements(By.tagName("tr"));
for (WebElement element : rows) {
String text = element.getText().trim();
for (String user : users) {
if (text.contains(user)) {
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element.findElement(By.tagName("input")));
}
}
}
}
@Then("^Click next$")
public void click_next() {
WebElement next = driver.findElement(By.xpath("//button[@id='actionButton']"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", next);
}
@Then("^Select start date$")
public void select_start_date(DataTable arg1) {
List<List<String>> data = arg1.raw();
String time = String.format("%d年%02d月%02d日", Integer.valueOf(data.get(0).get(0)), Integer.valueOf(data.get(0).get(1)), Integer.valueOf(data.get(0).get(2)));
WebElement dateButton = driver.findElement(By.id("ReportFrom"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", dateButton);
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(dateButton));
dateButton.clear();
// dateButton.click();
dateButton.sendKeys(Keys.DELETE);
dateButton.sendKeys(Keys.chord(Keys.COMMAND, "A"), time);
}
@Then("^Select end date$")
public void select_end_date(DataTable arg1) {
List<List<String>> data = arg1.raw();
String time = String.format("%d年%02d月%02d日", Integer.valueOf(data.get(0).get(0)), Integer.valueOf(data.get(0).get(1)), Integer.valueOf(data.get(0).get(2)));
WebElement dateButton = driver.findElement(By.id("ReportTo"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", dateButton);
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(dateButton));
dateButton.clear();
// dateButton.click();
dateButton.sendKeys(Keys.DELETE);
dateButton.sendKeys(Keys.chord(Keys.COMMAND, "A"), time);
}
@Then("^Click Search to download$")
public void click_Search_to_download() {
WebElement submit = driver.findElement(By.xpath("//button[@id='submitBtn']"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", submit);
}
@Then("^validate Download excel file$")
public void validate_Download_excel_file() throws Throwable {
// Write code here that turns the phrase above into concrete actions
System.out.print("tao validare roi");
}
}
package Runner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "C:\\Users\\DELL\\Downloads\\cucumber-sample\\Cucumbertest1\\src\\main\\java\\Feature",
glue= {"stepDefinition"},
dryRun = false,
monochrome = true,//display the console output in a proper readable format
strict=true,//it will check any step is not defined in step definition file
format = {"pretty", "html:test-out"})//check mapping betwwen feature and def file
public class TestRunner {
}
答案 0 :(得分:1)
这意味着您的步骤未实现。 (或者Cucumber找不到您的步骤的步骤定义。)