[Cucumber Framework] Main method not found in Step Definition File

Hello! Currently i am running through BDD Cucumber tutorial and more specific : Page object Design Pattern with Selenium Page Factory. The thing is that when i add latest code with page objects in Steps.class – i am getting the following error :

 

Error: Main method not found in class stepDefinitions.Steps , please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application.

Adding main method does not help in this case (and there isn`t such in the code given). Any help would be much appreciated!

 

 

 

 

 

Add Comment
  • 2 Answer(s)

    Thanks for answering! I tried this:

    unfortunately,  when I run the program – nothing happens – console says : <terminated>

    I don`t think that adding a main method is the solution here, as there is not main method in the given code in the tutorial :

     

    package stepDefinitions;
    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.WebDriver;
    
    import org.openqa.selenium.chrome.ChromeDriver;
    
    import cucumber.api.java.en.Given;
    
    import cucumber.api.java.en.When;
    
    import managers.PageObjectManager;
    
    import pageObjects.CartPage;
    
    import pageObjects.CheckoutPage;
    
    import pageObjects.HomePage;
    
    import pageObjects.ProductListingPage;
    public class Steps {
    
    WebDriver driver;
    
    HomePage homePage;
    
    ProductListingPage productListingPage;
    
    CartPage cartPage;
    
    CheckoutPage checkoutPage;
    
    PageObjectManager pageObjectManager;
    @Given("^user is on Home Page$")
    
    public void user_is_on_Home_Page(){
    
    System.setProperty("webdriver.chrome.driver","C:\\ToolsQA\\Libs\\Drivers\\chromedriver.exe");
    
    driver = new ChromeDriver();
    
    driver.manage().window().maximize();
    
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    
    pageObjectManager = new PageObjectManager(driver);
    
    homePage = pageObjectManager.getHomePage();
    
    homePage.navigateTo_HomePage();
    
    }
    @When("^he search for \"([^\"]*)\"$")
    
    public void he_search_for(String product) {
    
    homePage.perform_Search(product);
    
    }
    @When("^choose to buy the first item$")
    
    public void choose_to_buy_the_first_item() {
    
    productListingPage = pageObjectManager.getProductListingPage();
    
    productListingPage.select_Product(0);
    
    productListingPage.clickOn_AddToCart();
    
    }
    @When("^moves to checkout from mini cart$")
    
    public void moves_to_checkout_from_mini_cart(){
    
    cartPage = pageObjectManager.getCartPage();
    
    cartPage.clickOn_Cart();
    
    cartPage.clickOn_ContinueToCheckout();
    
    }
    @When("^enter personal details on checkout page$")
    
    public void enter_personal_details_on_checkout_page() throws InterruptedException {
    
    checkoutPage = pageObjectManager.getCheckoutPage();
    
    checkoutPage.fill_PersonalDetails();
    
    }
    @When("^select same delivery address$")
    
    public void select_same_delivery_address() throws InterruptedException{
    
    checkoutPage.check_ShipToDifferentAddress(false);
    
    }
    @When("^select payment method as \"([^\"]*)\" payment$")
    
    public void select_payment_method_as_payment(String arg1){
    
    checkoutPage.select_PaymentMethod("CheckPayment");
    
    }
    @When("^place the order$")
    
    public void place_the_order() throws InterruptedException {
    
    checkoutPage.check_TermsAndCondition(true);
    
    checkoutPage.clickOn_PlaceOrder();
    driver.quit();
    
    }
    
    }
    
    Default Answered on July 25, 2018.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.