Cucumber/TestNG - What am I doing wrong? Can't see step definition file...

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/learnjava

Our great sponsors
  • SonarQube - Static code analysis for 29 languages.
  • Scout APM - Less time debugging, more time building
  • SaaSHub - Software Alternatives and Reviews
  • duckduckgo-locales

    Translation files for duckduckgo.com

    package definitions; import io.cucumber.java.After; import io.cucumber.java.Before; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import static org.junit.Assert.assertTrue; import java.time.Duration; import java.util.ArrayList; import java.util.List; 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.AfterClass; import org.testng.annotations.BeforeClass; public class GoogleSiteStepDefs { private static WebDriver driver; private static String baseUrl; private static Duration dur; @Before public void setUp() { dur = Duration.ofSeconds(10); driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(dur); baseUrl = "https://duckduckgo.com"; } @After public void tearDown() { driver.quit(); } @Given("User goes to Home Page") public void user_goes_to_home_page() throws Exception { driver.get(baseUrl); } @When("User searches for {string}") public void user_searches_for(String subject) { WebElement searchBar = driver.findElement(By.xpath("//input[@id=\"search_form_input_homepage\"]")); searchBar.sendKeys("Pizza"); WebElement searchButton = driver.findElement(By.xpath("//input[@id=\"search_button_homepage\"]")); searchButton.submit(); } @Then("the result should show {string}") public void the_result_should_show(String subject) { List webElements = new ArrayList(); webElements = driver.findElements(By.xpath("//a[contains(text(), \"pizza\")]")); assertTrue(webElements.size() > 0); driver.quit(); } }

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts