Я только начала изучать Cucumber.
- .feature file coздала
- stepdefinition.java создала
- testrunner.java создала
Eclipse run configuration создала…
Проблема:
2 Scenarios (e[33m2 undefinede[0m)
6 Steps (e[33m6 undefinede[0m)
Running via Eclipse ->cucumber не видит мои степдефинитион и советует “You can implement missing steps with the snippets below:…”
package runner;
import java.io.IOException;
import org.testng.annotations.Test;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import cucumber.api.testng.TestNGCucumberRunner;
/*
* Helper class to provide Cucumber JVM configuration:
* -how to run feature with TestNG
*/
@Test(groups = "cucumber")
@CucumberOptions(
plugin={"pretty", "html:target/cucumber-html-report",
"json:target/cucumber-report.json"},
dryRun=false,
features ="src/test/resources/features/",
glue ="scr/main/java/stepdef/",
tags="@RunMe")
public class RunCukesTest extends AbstractTestNGCucumberTests {
@Test(groups = "cucumber", description = "Runs Cucumber Features")
public void run_cukes () throws IOException {
new TestNGCucumberRunner(getClass()).runCukes();
}
}
--------------------------------------------------------------------
@RunMe
Feature: Load google page
Scenario: Test Google Search
Given the user is on Google Home page
When user enters 'ifonly.com' as search item
And user submits search request
Then ensure search result contains 'IfOnly | Experience Gifts, Unique Experiences with Top ...'
----------------------------------------------------------------------
package stepdef;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeClass;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class GoogleStepDefs {
private WebDriver driver;
@BeforeClass
public void setUp(){
driver = new FirefoxDriver();
}
@Given("^the user is on Google Home page$")
public void user_is_on_google_home_page(){
driver.get("https://www.google.com/");
}
@When ("^user enters '([^']+)' as search item$")
public void user_enters_search_item(String searchItem){
WebElement searchcField=driver.findElement(By.id("lst-ib"));
searchcField.clear();
searchcField.sendKeys(searchItem);
}
@And ("^user submits request for search$")
public void user_submits_search_request(){
driver.findElement(By.name("btnG")).click();
}
@Then("^ensure search result contains '([^']+)'$")
public void ensure_search_result_contains(String searchResult){
WebElement searchResultEl = driver.findElement(By.xpath("//a[contains(.,'IfOnly | Experience Gifts, Unique Experiences with Top...')])[1]"));
Assert.assertTrue(searchResultEl.isDisplayed()==true);
}
//@AfterClass
public void tearDown(){
driver.quit();
}
}