[4864] | 1 | package org.expressolivre.cte.pages.calendar; |
---|
| 2 | |
---|
[4962] | 3 | import java.util.List; |
---|
| 4 | |
---|
[4864] | 5 | import org.expressolivre.cte.pages.common.Page; |
---|
| 6 | import org.openqa.selenium.Alert; |
---|
[4962] | 7 | import org.openqa.selenium.By; |
---|
[4864] | 8 | import org.openqa.selenium.WebDriver; |
---|
| 9 | import org.openqa.selenium.WebElement; |
---|
| 10 | import org.openqa.selenium.support.FindBy; |
---|
[4902] | 11 | import org.openqa.selenium.support.PageFactory; |
---|
[4864] | 12 | import org.testng.Assert; |
---|
| 13 | |
---|
| 14 | /** |
---|
| 15 | * @author L.F.Estivalet (Serpro) |
---|
| 16 | * |
---|
| 17 | * Created on Jul 25, 2011 at 2:25:28 PM |
---|
| 18 | * |
---|
| 19 | */ |
---|
| 20 | public class AppointmentViewPage extends Page { |
---|
| 21 | |
---|
[4962] | 22 | public static final String DESCRIPTION = "Descrição:"; |
---|
| 23 | public static final String LOCAL = "Localização:"; |
---|
[5025] | 24 | public static final String START = "InÃcio Data/hora:"; |
---|
[4962] | 25 | public static final String END = "Data/Hora de término:"; |
---|
| 26 | public static final String PRIORITY = "Prioridade:"; |
---|
| 27 | public static final String ACCESS = "Acesso:"; |
---|
| 28 | public static final String PARTICIPANTS = "Participantes:"; |
---|
| 29 | public static final String CREATED_BY = "Criado por:"; |
---|
| 30 | public static final String UPDATED = "Atualizado:"; |
---|
| 31 | public static final String LAST_UPDATED_BY = "Ãltima alteração realizada por:"; |
---|
| 32 | public static final String ATTACHMENTS = "Anexos:"; |
---|
| 33 | |
---|
[4917] | 34 | /** Botao para editar um compromisso. */ |
---|
[4864] | 35 | @FindBy(xpath = "//table[@id='calendar_viewevent_button_left']/tbody/tr/td[1]/nobr/form/div/input[@id='']") |
---|
| 36 | private WebElement editButton; |
---|
| 37 | |
---|
[4917] | 38 | /** Botao para editar serie de compromissos. */ |
---|
[4864] | 39 | @FindBy(xpath = "//table[@id='calendar_viewevent_button_left']/tbody/tr/td[2]/nobr/form/div/input[@id='']") |
---|
[4917] | 40 | private WebElement editSeriesButton; |
---|
[4864] | 41 | |
---|
[5025] | 42 | @FindBy(xpath = "//table[@id='calendar_viewevent_button_left']/tbody/tr/td[2]/nobr/form/div/input[@id='']") |
---|
| 43 | private WebElement readyButton; |
---|
| 44 | |
---|
[4864] | 45 | @FindBy(xpath = "//table[@id='calendar_viewevent_button_right']/tbody/tr/td/nobr/form/div/input[@id='']") |
---|
| 46 | private WebElement removeButton; |
---|
| 47 | |
---|
[4890] | 48 | @FindBy(xpath = "//table[@id='calendar_viewevent_button_right']/tbody/tr/td[2]/nobr/form/div/input[@id='']") |
---|
| 49 | private WebElement removeSeriesButton; |
---|
| 50 | |
---|
[4864] | 51 | @FindBy(xpath = "//table[@id='calendar_view_event']/tbody/tr[1]/td[2]") |
---|
| 52 | private WebElement title; |
---|
| 53 | |
---|
| 54 | public AppointmentViewPage(WebDriver driver) { |
---|
| 55 | super(driver); |
---|
| 56 | // TODO Auto-generated constructor stub |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | /** |
---|
[4917] | 60 | * Edita o compromisso previamente selecionado. |
---|
[4902] | 61 | * |
---|
| 62 | * @return Retorna pagina de edicao do compromisso. |
---|
[4864] | 63 | */ |
---|
[4902] | 64 | public AppointmentEditPage editAppointment() { |
---|
| 65 | this.editButton.click(); |
---|
| 66 | return PageFactory.initElements(driver, AppointmentEditPage.class); |
---|
[4864] | 67 | |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | /** |
---|
[4917] | 71 | * Edita a serie de compromissos previamente selecionado. |
---|
| 72 | * |
---|
| 73 | * @return Retorna pagina de edicao do compromisso. |
---|
| 74 | */ |
---|
| 75 | public AppointmentEditPage editAppointmentSeries() { |
---|
| 76 | this.editSeriesButton.click(); |
---|
| 77 | return PageFactory.initElements(driver, AppointmentEditPage.class); |
---|
| 78 | |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | /** |
---|
[4902] | 82 | * Remove um compromisso. |
---|
[4864] | 83 | */ |
---|
[4902] | 84 | public void removeAppointment() { |
---|
| 85 | this.removeButton.click(); |
---|
| 86 | this.removeAlert(); |
---|
[4864] | 87 | } |
---|
| 88 | |
---|
| 89 | /** |
---|
[5025] | 90 | * |
---|
| 91 | */ |
---|
| 92 | public void ready() { |
---|
| 93 | this.readyButton.click(); |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | /** |
---|
[4902] | 97 | * Remove a serie de compromissos. |
---|
[4864] | 98 | */ |
---|
[4902] | 99 | public void removeSeriesAppointment() { |
---|
| 100 | this.removeSeriesButton.click(); |
---|
| 101 | this.removeAlert(); |
---|
[4864] | 102 | } |
---|
| 103 | |
---|
| 104 | /** |
---|
[4902] | 105 | * Exibe alerta ao tentar remover um compromisso. |
---|
[4864] | 106 | */ |
---|
[4902] | 107 | private void removeAlert() { |
---|
| 108 | Alert alert = driver.switchTo().alert(); |
---|
| 109 | Assert.assertEquals( |
---|
| 110 | alert.getText(), |
---|
| 111 | "Tem certeza que deseja remover esta entrada?\nIsto irá remover esta entrada para todos usuários."); |
---|
| 112 | alert.accept(); |
---|
[4864] | 113 | } |
---|
| 114 | |
---|
| 115 | /** |
---|
[4902] | 116 | * @return the title |
---|
[4864] | 117 | */ |
---|
[4902] | 118 | public String getTitle() { |
---|
| 119 | return title.getText(); |
---|
[4864] | 120 | } |
---|
[4962] | 121 | |
---|
| 122 | /** |
---|
| 123 | * Percorre a tabela em busca da informacao desejada. |
---|
| 124 | * |
---|
| 125 | * @param label |
---|
| 126 | * Informa o label procurado. Ex: "Descrição". |
---|
| 127 | * @return Retorna o valor correspondente ao label encontrado. Se label nao |
---|
| 128 | * for encontrado retorna <code>null</code>. |
---|
| 129 | */ |
---|
| 130 | public String getAppointmentInfo(String label) { |
---|
| 131 | List<WebElement> rows = driver.findElements(By |
---|
| 132 | .xpath("//table[@id='calendar_view_event']/tbody/tr")); |
---|
| 133 | // Comeca a partir da linha 2 pois a linha eh sempre o titulo do |
---|
| 134 | // compromisso. |
---|
| 135 | for (int i = 2; i <= rows.size(); i++) { |
---|
| 136 | WebElement row = driver.findElement(By |
---|
| 137 | .xpath("//table[@id='calendar_view_event']/tbody/tr[" + i |
---|
| 138 | + "]/td[1]")); |
---|
| 139 | // Se o label for encontrado entao pega o valor encontrado na |
---|
| 140 | // segunda coluna da tabela. |
---|
| 141 | if (label.equals(row.getText())) { |
---|
| 142 | return driver.findElement( |
---|
| 143 | By.xpath("//table[@id='calendar_view_event']/tbody/tr[" |
---|
| 144 | + i + "]/td[2]")).getText(); |
---|
| 145 | } |
---|
| 146 | } |
---|
| 147 | return null; |
---|
| 148 | } |
---|
[4864] | 149 | } |
---|