[3488] | 1 | /** |
---|
| 2 | * Autor : Alexandre Correia - alexandrecorreia@celepar.pr.gov.br |
---|
| 3 | * Data : 00/00/0000 |
---|
| 4 | * Caso de Teste : EL-947 : Adicionar Compromisso com Data Final Anterior a Data Inicial |
---|
| 5 | * |
---|
| 6 | * Descrição do Processo de Teste Cadastro no TestLink - http://testlink.expressolivre.org/ |
---|
| 7 | * |
---|
| 8 | * AÇÕES DO PASSO |
---|
| 9 | * P01. Usuário informa um título para o compromisso; |
---|
| 10 | * P02. Usuário informa uma data inicial para o compromisso; |
---|
| 11 | * P03. Usuário informa uma data final para o compromisso menor que a data inicial; |
---|
| 12 | * P04. Usuário pressiona opção para salvar o compromisso; |
---|
| 13 | * P05. Sistema exibe uma mensagem de erro informando o Usuário que a data final não pode ser inferior a data inicial e não salva o compromisso; |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | package br.gov.serpro.cte.agenda.casoteste; |
---|
| 17 | |
---|
| 18 | import java.util.GregorianCalendar; |
---|
| 19 | |
---|
| 20 | import org.junit.After; |
---|
| 21 | import org.junit.Before; |
---|
| 22 | import org.junit.Test; |
---|
| 23 | |
---|
| 24 | import br.gov.serpro.cte.agenda.Objetos.AdicionarCompromissoEL947.Campo; |
---|
| 25 | import br.gov.serpro.cte.agenda.Objetos.AdicionarCompromissoEL947.Valor; |
---|
| 26 | import br.gov.serpro.cte.connection.DAOSelenium; |
---|
| 27 | import br.gov.serpro.cte.connection.LoginExpresso; |
---|
| 28 | |
---|
| 29 | import com.thoughtworks.selenium.SeleneseTestCase; |
---|
| 30 | |
---|
| 31 | public class Test_EL_947_AdicionarCompromissoComDataFinalAnteriorDataInicial extends SeleneseTestCase |
---|
| 32 | { |
---|
| 33 | @Before |
---|
| 34 | public void setUp() throws Exception |
---|
| 35 | { |
---|
| 36 | String url = "https://cte.serpro.gov.br"; |
---|
| 37 | DAOSelenium conn = new DAOSelenium( "localhost", 4444, "*pifirefox", url); |
---|
| 38 | selenium = conn.newConnection(); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | @Test |
---|
| 42 | public void testa() |
---|
| 43 | { |
---|
| 44 | // Logando No Expresso |
---|
| 45 | selenium.open("/login.php"); |
---|
| 46 | selenium.type("user", LoginExpresso.USER_EXPRESSO.getValue()); |
---|
| 47 | selenium.type("passwd", LoginExpresso.PASSWORD_EXPRESSO.getValue()); |
---|
| 48 | selenium.click("submitit"); |
---|
| 49 | selenium.waitForPageToLoad("30000"); |
---|
| 50 | selenium.click("//html/body/div[@id='toolbar']/table/tbody/tr/td[2]/table/tbody/tr/td[3]/a/img[@id='calendarid']"); |
---|
| 51 | |
---|
| 52 | // Data |
---|
| 53 | GregorianCalendar gc = new GregorianCalendar(); |
---|
| 54 | String Dia = String.valueOf( gc.get( gc.DAY_OF_MONTH ) ); |
---|
| 55 | Dia = ( Dia.length() > 1 ) ? Dia : "0"+Dia; |
---|
| 56 | |
---|
| 57 | String Mes = String.valueOf( gc.get( gc.MONTH ) + 1 ); |
---|
| 58 | |
---|
| 59 | String Ano = String.valueOf( gc.get( gc.YEAR ) ); |
---|
| 60 | |
---|
| 61 | //Adicionando um Evento |
---|
| 62 | selenium.open("/index.php?date=" + Ano + Mes + Dia + "&menuaction=calendar.uicalendar.week"); |
---|
| 63 | selenium.click("//img[@title='Nova Entrada']"); |
---|
| 64 | selenium.waitForPageToLoad("30000"); |
---|
| 65 | |
---|
| 66 | for( Campo cmp : Campo.values() ) |
---|
| 67 | { |
---|
| 68 | String cmpName = cmp.name(); |
---|
| 69 | |
---|
| 70 | if( cmp.getValue().indexOf("addSelection:") > -1 ) |
---|
| 71 | { |
---|
| 72 | AddSelection( cmp.getValue(), getValor( cmp.name() ) ); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | if( cmp.getValue().indexOf("click:") > -1 ) |
---|
| 76 | { |
---|
| 77 | Click( cmp.getValue() ); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | if( cmp.getValue().indexOf("select:") > -1 ) |
---|
| 81 | { |
---|
| 82 | Select( cmp.getValue(), getValor( cmp.name() ) ); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | if( cmp.getValue().indexOf("type:") > -1 ) |
---|
| 86 | { |
---|
| 87 | Type( cmp.getValue(), getValor( cmp.name() ) ); |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | selenium.waitForPageToLoad("15000"); |
---|
| 92 | |
---|
| 93 | // Verifica a Mensagem de Erro |
---|
| 94 | selenium.isTextPresent("Você informou uma data inválida."); |
---|
| 95 | |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | public String getValor(String cmpName) |
---|
| 99 | { |
---|
| 100 | String _return = ""; |
---|
| 101 | |
---|
| 102 | for( Valor vlr : Valor.values() ) |
---|
| 103 | { |
---|
| 104 | String vlrName = vlr.name(); |
---|
| 105 | |
---|
| 106 | if( vlrName.equals( cmpName ) ) |
---|
| 107 | { |
---|
| 108 | _return = vlr.getValue(); |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | return _return; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | public void AddSelection( String locator, String optionLocator ) |
---|
| 116 | { |
---|
| 117 | selenium.addSelection( locator.substring( 13 , locator.length() ), optionLocator ); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | public void Click( String locator ) |
---|
| 121 | { |
---|
| 122 | selenium.click( locator.substring( 6 , locator.length() ) ); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | public void Select( String selectLocator, String optionLocator ) |
---|
| 126 | { |
---|
| 127 | selenium.select( selectLocator.substring( 7 , selectLocator.length() ), optionLocator ); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | public void Type( String locator, String value ) |
---|
| 131 | { |
---|
| 132 | selenium.type( locator.substring( 5 , locator.length() ), value ); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | @After |
---|
| 136 | public void tearDown() throws Exception |
---|
| 137 | { |
---|
| 138 | selenium.close(); |
---|
| 139 | } |
---|
| 140 | } |
---|