/**
 * Created with IntelliJ IDEA.
 * User: jhasmanyquiroz
 * Date: 11/12/15
 * Time: 3:02 PM
 * To change this template use File | Settings | File Templates.
 */
package steps;

import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import ui.PageTransporter;
import ui.pages.*;

import static org.testng.Assert.assertTrue;

public class SearchCourseSteps {
    private static PageTransporter page = PageTransporter.getInstance();
    private MainPage mainPage;
    private HomePage homePage;
    private LoginPage loginPage;
    private CoursesPage coursesPage;
    private CourseInformationPage courseInformationPage;
    private CoursePage coursePage;

    @Given("^I navigate to Main Page$")
    public void navigateToMainPage() {
        mainPage = page.navigateToMainPage();
    }

    @When("^I search a course as \"(.*?)\"$")
    public void searchACourseAs(String searchCourse) {
        coursesPage = mainPage
                    .setSearchCourseInput(searchCourse)
                    .clickSearchButton();
    }

    @When("^I search a course like \"(.*?)\"$")
    public void searchACourseLike(String searchCourse) {
        coursesPage = homePage
                .setSearchCourseInput(searchCourse)
                .clickSearchButton();
    }

    @When("^I login like \"(.*?)\" with password \"(.*?)\"$")
    public void loginLike(String userName, String userPassword){
        loginPage = mainPage.clickLogInButton();
        homePage = loginPage.loginSuccessful(userName, userPassword);
    }

    @Then("^obtain a \"(.*?)\" list course.$")
    public void obtainAJavaScriptListCourse(String course) {
        assertTrue(coursesPage.coursesFinds(course), "Courses are displayed");
    }

    @Then("^do not obtain \"(.*?)\" none course.$")
    public void doNotObtainNoneCourse(String course) {
        assertTrue(coursesPage.notCourseFind(course), "Courses aren't displayed");
    }

    //Enroll the course
    @When("^I wish to enroll in the course \"(.*?)\"$")
    public void iWishToEnrollInTheCourse(String course) {
        courseInformationPage = coursesPage
                                .selectTheCourse(course)
                                .clickEnrollButtonSuccessful();
    }

    @And("^Sign the Coursera Honor Code.$")
    public void signTheCourseraHonorCode() {
    }

    @Then("^go to the course enrolled.$")
    public void goToTheCourseEnrolled() {
        coursePage = courseInformationPage.clickGoToCourseSuccessfull();
    }
}
@@ -172,16 +172,54 @@
 steps;%0A%0A
+import cucumber.api.PendingException;%0A
 import c
@@ -2583,10 +2583,566 @@
 );%0A    %7D
+%0A%0A    @When(%22%5EI navigate to Home Page$%22)%0A    public void iNavigateToHomePage() %7B%0A        homePage = page.navigateToHomePage();%0A    %7D%0A%0A    @And(%22%5EI selected the course to unenroll %5C%22(%5B%5E%5C%22%5D*)%5C%22$%22)%0A    public void iSelectedTheCourseToUnenroll(String nameCourse) %7B%0A        //homePage = homePage%0A                    homePage.searchCourse(nameCourse);%0A                    //.clickDropdownMenuCourse();%0A    %7D%0A%0A    @Then(%22%5Ethe registered course %5C%22(%5B%5E%5C%22%5D*)%5C%22 should not be present.$%22)%0A    public void theRegisteredCourseShouldNotBePresent(String nameCourse) %7B%0A    %7D
 %0A%7D

Add steps for a search a course