package org.expressolivre.cte.pages.calendar; import org.expressolivre.cte.pages.common.Page; import org.openqa.selenium.Alert; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.testng.Assert; /** * @author L.F.Estivalet (Serpro) * * Created on Jul 25, 2011 at 2:25:28 PM * */ public class AppointmentViewPage extends Page { /** Botao para editar um compromisso. */ @FindBy(xpath = "//table[@id='calendar_viewevent_button_left']/tbody/tr/td[1]/nobr/form/div/input[@id='']") private WebElement editButton; /** Botao para editar serie de compromissos. */ @FindBy(xpath = "//table[@id='calendar_viewevent_button_left']/tbody/tr/td[2]/nobr/form/div/input[@id='']") private WebElement editSeriesButton; @FindBy(xpath = "//table[@id='calendar_viewevent_button_right']/tbody/tr/td/nobr/form/div/input[@id='']") private WebElement removeButton; @FindBy(xpath = "//table[@id='calendar_viewevent_button_right']/tbody/tr/td[2]/nobr/form/div/input[@id='']") private WebElement removeSeriesButton; @FindBy(xpath = "//table[@id='calendar_view_event']/tbody/tr[1]/td[2]") private WebElement title; public AppointmentViewPage(WebDriver driver) { super(driver); // TODO Auto-generated constructor stub } /** * Edita o compromisso previamente selecionado. * * @return Retorna pagina de edicao do compromisso. */ public AppointmentEditPage editAppointment() { this.editButton.click(); return PageFactory.initElements(driver, AppointmentEditPage.class); } /** * Edita a serie de compromissos previamente selecionado. * * @return Retorna pagina de edicao do compromisso. */ public AppointmentEditPage editAppointmentSeries() { this.editSeriesButton.click(); return PageFactory.initElements(driver, AppointmentEditPage.class); } /** * Remove um compromisso. */ public void removeAppointment() { this.removeButton.click(); this.removeAlert(); } /** * Remove a serie de compromissos. */ public void removeSeriesAppointment() { this.removeSeriesButton.click(); this.removeAlert(); } /** * Exibe alerta ao tentar remover um compromisso. */ private void removeAlert() { Alert alert = driver.switchTo().alert(); Assert.assertEquals( alert.getText(), "Tem certeza que deseja remover esta entrada?\nIsto irá remover esta entrada para todos usuários."); alert.accept(); } /** * @return the title */ public String getTitle() { return title.getText(); } }