/**
 * Created with IntelliJ IDEA.
 * User: jhasmanyquiroz
 * Date: 11/11/15
 * Time: 11:59 AM
 * To change this template use File | Settings | File Templates.
 */
package ui.pages;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import ui.BasePageObject;

public class HomePage extends BasePageObject {
    @FindBy(linkText = "Institutions")
    @CacheLookup
    private WebElement linkText;

    @FindBy(xpath = "(//input[@value=''])[2]")
    private  WebElement searchCatalog;

    @FindBy(css = "i.cif-search.c-search-icon")
    private WebElement searchIcon;

    @FindBy(xpath = "//a[contains(@data-popup-bind-open, 'click')]")
    private  WebElement authenticatedDropdownBtn;

    @FindBy(xpath = "//button[contains(@class, 'bt3-btn-link')]")
    private  WebElement signOutBtn;

    @FindBy(xpath = "//div[contains(@class, 'dashboard-has-enrollment')]")
    private WebElement dashboardEnrollment;

    public HomePage(){
        PageFactory.initElements(driver, this);
        waitUntilPageObjectIsLoaded();
    }

    public boolean isPartnersDisplayed() {
        return (linkText.getText().equalsIgnoreCase("Institutions"))? true : false;
    }

    public HomePage setSearchCourseInput (String searchCourse) {
        searchCatalog.clear();
        searchCatalog.sendKeys(searchCourse);
        return this;
    }

    public CoursesPage clickSearchButton() {
        searchIcon.click();
        return new CoursesPage();
    }

    public HomePage clickAuthenticatedDropdownButton() {
        authenticatedDropdownBtn.click();
        return new HomePage();
    }

    public LoginPage clickSignOutButton() {
        signOutBtn.click();
        return new LoginPage();
    }

    public void waitUntilPageObjectIsLoaded() {
        wait.until(ExpectedConditions.visibilityOf(dashboardEnrollment));
    }
}
@@ -176,16 +176,47 @@
 pages;%0A%0A
+import org.openqa.selenium.By;%0A
 import o
@@ -246,16 +246,16 @@
 lement;%0A
-
 import o
@@ -470,16 +470,67 @@
 bject;%0A%0A
+import java.util.Iterator;%0Aimport java.util.List;%0A%0A
 public c
@@ -1168,24 +1168,139 @@
 nrollment;%0A%0A
+    @FindBy(xpath = %22//div%5Bcontains(@data-js, 'list-items-container')%5D//div%22)%0A    private WebElement listCourses;%0A%0A
     public H
@@ -2055,39 +2055,791 @@
 ew LoginPage();%0A
-
     %7D%0A%0A
+    public boolean searchCourse(String nameCourse) %7B%0A        boolean res = false;%0A        List%3CWebElement%3E courses = listCourses.findElements(By.tagName(%22div%22));%0A        System.out.println(%22Cursos: %22 + courses);%0A        Iterator%3CWebElement%3E iterator = courses.iterator();%0A%0A        while (iterator.hasNext() && !res) %7B%0A            WebElement course = iterator%0A                                .next()%0A                                .findElement(By.xpath(%22//div%5Bcontains(@data-js, 'course-nameundefined')%5D%22));%0A            System.out.println(%22Curso: %22 + course.getText());%0A%0A            if (course.getText().equalsIgnoreCase(nameCourse))%0A                res = true;%0A        %7D%0A%0A        return res;%0A    %7D%0A%0A    //public HomePage clickDropdownMenuCourse() %7B%7D%0A%0A
     public void 

Add the methods for search a course and web elements