Ignore:
Timestamp:
09/02/11 14:27:19 (13 years ago)
Author:
luiz-fernando
Message:

Ticket #1771 - Adicionado testes automatizados para modulo da agenda

Location:
devel/testlink/automation2.0/src/test/java/org/expressolivre/cte
Files:
8 added
19 edited

Legend:

Unmodified
Added
Removed
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoDataFinalMenorDataInicialTestCase.java

    r4902 r5025  
    6262                ap.saveAppointment(); 
    6363 
    64                 Assert.assertEquals("Você informou uma data inválida.", 
    65                                 ap.getFormStatus()); 
     64                Assert.assertEquals(ap.getFormStatus(), 
     65                                "Você informou uma data inválida."); 
    6666 
    6767        } 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoDataInicialFinalInvalidaTestCase.java

    r4902 r5025  
    5858                ap.saveAppointment(); 
    5959 
    60                 Assert.assertEquals("Você informou uma data inválida.", 
    61                                 ap.getFormStatus()); 
     60                Assert.assertEquals(ap.getFormStatus(), 
     61                                "Você informou uma data inválida."); 
    6262 
    6363        } 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoHoraFinalMenorHoraInicialTestCase.java

    r4902 r5025  
    5858 
    5959                Assert.assertEquals( 
    60                                 "A hora de inicio não pode ser maior do que a hora de término.", 
    61                                 ap.getFormStatus()); 
     60 
     61                ap.getFormStatus(), 
     62                                "A hora de inicio não pode ser maior do que a hora de término."); 
    6263 
    6364        } 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraAgendaTestCase.java

    r4962 r5025  
    2929                AgendaPermissionPage app = super.openAgendaPermissionPage(); 
    3030 
    31                 AgendaAddACLUserPage aaaup = app.addUserACL(); 
    32                 aaaup.setOrganization(organizacao); 
    33                 aaaup.setSector(setor); 
    34                 aaaup.selectUser(nomeUsuario); 
    35                 aaaup.addUser(); 
    36                 aaaup.close(); 
    37  
    38                 app.setReadPermission(); 
    39                 app.cancel(); 
     31                if (!app.isUserInList(nomeUsuario)) { 
     32                        AgendaAddACLUserPage aaaup = app.addUserACL(); 
     33                        aaaup.setOrganization(organizacao); 
     34                        aaaup.setSector(setor); 
     35                        aaaup.selectUser(nomeUsuario); 
     36                        aaaup.addUser(); 
     37                        aaaup.close(); 
     38                } 
     39                app.clearPemissions(); 
     40                app.setReadPermission(true); 
     41                app.apply(); 
    4042        } 
    4143 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/AceitarCompromissoTestCase.java

    r4962 r5025  
    2424        public void aceitarCompromisso(String titulo, 
    2525 
    26         @Optional("") String dataInicial, String horaInicial, String minutoInicial) { 
     26        @Optional("") String dataInicial, String horaInicial, String minutoInicial) 
     27                        throws Exception { 
    2728 
    2829                Calendar cal = Calendar.getInstance(); 
     
    4041                AppointmentEmailPage aep = mp.readAppointmentEmail(assunto); 
    4142                AppointmentStatusPage asp = aep.accept(id); 
    42                 Assert.assertEquals(asp.getMessage(), 
    43                                 "O compromisso foi aceito com sucesso!"); 
    44                 asp.close(); 
     43                System.out.println("antes assert"); 
     44                String message = asp.getMessage(); 
     45 
     46                System.out.println("depois assert"); 
     47                aep = asp.close(); 
     48                // TODO espera um tempo ate a janela popup fechar. Rever essa 
     49                // implementacao pois o close acima nao esta funcionando como deveria. 
     50                // super.dummyWait(5); 
     51                Assert.assertEquals(message, "O compromisso foi aceito com sucesso!"); 
    4552        } 
    4653} 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/EditarCompromissoRecorrente1OcorrenciaTestCase.java

    r4917 r5025  
    4747 
    4848                AppointmentEditPage aep = avp.editAppointment(); 
     49                aep.setTitle(novoTitulo); 
    4950                aep.setLocation(novoLocal); 
    5051                aep.setStartHour(novaHoraInicial); 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/ExibirCompromissoTestCase.java

    r4965 r5025  
    5353                                avp.getAppointmentInfo(AppointmentViewPage.PRIORITY), 
    5454                                prioridade); 
     55 
     56                avp.ready(); 
    5557        } 
    5658} 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/MarcarTentativaCompromissoTestCase.java

    r4962 r5025  
    4242                AppointmentEmailPage aep = mp.readAppointmentEmail(assunto); 
    4343                AppointmentStatusPage asp = aep.tentative(id); 
    44                 Assert.assertEquals(asp.getMessage(), 
    45                                 "O compromisso foi aceito com sucesso!"); 
     44                String message = asp.getMessage(); 
    4645                aep = asp.close(); 
    4746 
    4847                // TODO espera um tempo ate a janela popup fechar. Rever essa 
    4948                // implementacao pois o close acima nao esta funcionando como deveria. 
    50                 super.dummyWait(5); 
     49                // super.dummyWait(10); 
    5150 
    5251                AppointmentViewPage avp = aep.viewAppointment(id); 
     
    5453                                .getAppointmentInfo(AppointmentViewPage.PARTICIPANTS)); 
    5554 
     55                Assert.assertEquals(message, "O compromisso foi aceito com sucesso!"); 
    5656        } 
    5757} 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/RejeitarCompromissoTestCase.java

    r4962 r5025  
    4242                AppointmentEmailPage aep = mp.readAppointmentEmail(assunto); 
    4343                AppointmentStatusPage asp = aep.reject(id); 
    44                 Assert.assertEquals(asp.getMessage(), 
    45                                 "O compromisso foi rejeitado com sucesso!"); 
     44                String message = asp.getMessage(); 
    4645                aep = asp.close(); 
    4746 
    4847                // TODO espera um tempo ate a janela popup fechar. Rever essa 
    4948                // implementacao pois o close acima nao esta funcionando como deveria. 
    50                 super.dummyWait(5); 
     49                // super.dummyWait(10); 
    5150 
    5251                AppointmentViewPage avp = aep.viewAppointment(id); 
    5352                System.out.println(avp 
    5453                                .getAppointmentInfo(AppointmentViewPage.PARTICIPANTS)); 
     54 
     55                Assert.assertEquals(message, "O compromisso foi rejeitado com sucesso!"); 
     56 
    5557        } 
    5658} 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/common/BaseTestCase.java

    r4962 r5025  
    8282        @AfterSuite 
    8383        public void afterSuite() { 
    84                 driver.close(); 
     84                // driver.close(); 
     85                driver.quit(); 
    8586        } 
    8687 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/email/compor/SalvarEmailSomenteCopiaOcultaTestCase.java

    r4606 r5025  
    4444                Assert.assertEquals(EMAIL_TESTE_1, mp.getBlindCarbonCopy(id).getValue()); 
    4545                String body = mp.getBody(id).toString(); 
     46 
    4647                // Retirar o <span></span> que é colocado no momento de visualizar o 
    4748                // email para edicao. 
    48                 int spanOpen = body.indexOf("<span>") + 7; 
    49                 int spanClose = body.lastIndexOf("</span>") - 1; 
     49                int spanOpen = body.indexOf("<span><span>") + 13; 
     50                int spanClose = body.lastIndexOf("</span></span>") - 1; 
    5051                body = body.substring(spanOpen, spanClose).trim(); 
    51                 Assert.assertEquals(EMAIL_TEXTO_SALVAR_SOMENTE_COPIA_OCULTA, body); 
     52 
     53                System.out.println(body); 
    5254 
    5355                mp.closeMail(id, true); 
     56 
     57                Assert.assertEquals(EMAIL_TEXTO_SALVAR_SOMENTE_COPIA_OCULTA, body); 
    5458        } 
    5559 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/email/compor/SalvarEmailSomenteCopiaTestCase.java

    r4606 r5025  
    4545                // Retirar o <span></span> que é colocado no momento de visualizar o 
    4646                // email para edicao. 
    47                 int spanOpen = body.indexOf("<span>") + 7; 
    48                 int spanClose = body.lastIndexOf("</span>") - 1; 
     47                int spanOpen = body.indexOf("<span><span>") + 13; 
     48                int spanClose = body.lastIndexOf("</span></span>") - 1; 
    4949                body = body.substring(spanOpen, spanClose).trim(); 
     50 
     51                mp.closeMail(id, true); 
    5052 
    5153                Assert.assertEquals(EMAIL_TEXTO_SALVAR_SOMENTE_COPIA, body); 
    5254 
    53                 mp.closeMail(id, true); 
    5455        } 
    5556 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AgendaPermissionPage.java

    r4962 r5025  
    11package org.expressolivre.cte.pages.calendar; 
    22 
     3import java.util.List; 
    34import java.util.Set; 
    45 
     
    6061 
    6162        /** 
     63         * Verifica se o usuario ja esta na lista de permissoes. 
     64         *  
     65         * @param userName 
     66         * @return 
     67         */ 
     68        public Boolean isUserInList(String userName) { 
     69                return super.isValueInCombo(this.userList, userName, true); 
     70        } 
     71 
     72        /** 
     73         * Remove todos os usuarios do compartilhamento. 
     74         */ 
     75        public void removeAllUsers() { 
     76                List<WebElement> users = super.getComboElements(this.userList); 
     77                for (WebElement user : users) { 
     78                        user.setSelected(); 
     79                        this.removeButton.click(); 
     80                } 
     81        } 
     82 
     83        /** 
    6284         * Adaptacao da solucao para lidar com janelas popups obtida em <a 
    6385         * href="http://groups.google.com/group 
     
    92114        } 
    93115 
    94         public void setReadPermission() { 
    95                 this.read.click(); 
     116        public void setReadPermission(boolean read) { 
     117                if (read && !this.read.isSelected()) { 
     118                        this.read.click(); 
     119                } else if (!read && this.read.isSelected()) { 
     120                        this.read.click(); 
     121                } 
     122        } 
     123 
     124        public void setEditPermission(boolean edit) { 
     125                if (edit && !this.edit.isSelected()) { 
     126                        this.edit.click(); 
     127                } else if (!edit && this.edit.isSelected()) { 
     128                        this.edit.click(); 
     129                } 
     130        } 
     131 
     132        public void setAddPermission(boolean add) { 
     133                if (add && !this.add.isSelected()) { 
     134                        this.add.click(); 
     135                } else if (!add && this.add.isSelected()) { 
     136                        this.add.click(); 
     137                } 
     138        } 
     139 
     140        public void setRemovePermission(boolean remove) { 
     141                if (remove && !this.remove.isSelected()) { 
     142                        this.remove.click(); 
     143                } else if (!remove && this.remove.isSelected()) { 
     144                        this.remove.click(); 
     145                } 
     146        } 
     147 
     148        public void setRestrictPermission(boolean restrict) { 
     149                if (restrict && !this.restrict.isSelected()) { 
     150                        this.restrict.click(); 
     151                } else if (!restrict && this.restrict.isSelected()) { 
     152                        this.restrict.click(); 
     153                } 
     154        } 
     155 
     156        public void clearPemissions() { 
     157                this.setReadPermission(false); 
     158                this.setEditPermission(false); 
     159                this.setRemovePermission(false); 
     160                this.setAddPermission(false); 
     161                this.setRestrictPermission(false); 
    96162        } 
    97163 
     
    99165                this.cancelButton.click(); 
    100166        } 
     167 
     168        public void apply() { 
     169                this.okButton.click(); 
     170        } 
    101171} 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentEmailPage.java

    r4962 r5025  
    4242 
    4343                // wait for the new window to open 
    44                 new WebDriverWait(driver, 30) { 
     44                new WebDriverWait(driver, 100) { 
    4545                }.until(new ExpectedCondition<Boolean>() { 
    4646                        public Boolean apply(WebDriver driver) { 
     
    5858                String newWindowHandle = afterHandles.iterator().next(); 
    5959                driver.switchTo().window(newWindowHandle); 
     60                driver.switchTo().defaultContent(); 
    6061 
    6162                return PageFactory.initElements(driver, AppointmentStatusPage.class); 
     
    7374 
    7475                // wait for the new window to open 
    75                 new WebDriverWait(driver, 30) { 
     76                new WebDriverWait(driver, 100) { 
    7677                }.until(new ExpectedCondition<Boolean>() { 
    7778                        public Boolean apply(WebDriver driver) { 
     
    8990                String newWindowHandle = afterHandles.iterator().next(); 
    9091                driver.switchTo().window(newWindowHandle); 
     92                driver.switchTo().defaultContent(); 
    9193 
    9294                return PageFactory.initElements(driver, AppointmentStatusPage.class); 
     
    104106 
    105107                // wait for the new window to open 
    106                 new WebDriverWait(driver, 30) { 
     108                new WebDriverWait(driver, 100) { 
    107109                }.until(new ExpectedCondition<Boolean>() { 
    108110                        public Boolean apply(WebDriver driver) { 
     
    120122                String newWindowHandle = afterHandles.iterator().next(); 
    121123                driver.switchTo().window(newWindowHandle); 
     124                driver.switchTo().defaultContent(); 
    122125 
    123126                return PageFactory.initElements(driver, AppointmentStatusPage.class); 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentStatusPage.java

    r4962 r5025  
    44 
    55import org.expressolivre.cte.pages.common.Page; 
     6import org.openqa.selenium.By; 
    67import org.openqa.selenium.WebDriver; 
    78import org.openqa.selenium.WebElement; 
     
    3435 
    3536        public String getMessage() { 
     37                super.waitForElement(By 
     38                                .xpath("/html/body/center[1]/table/tbody/tr[1]/td/b/font")); 
    3639                return this.message.getText(); 
    3740        } 
     
    4952 
    5053                // wait for the new window to close 
    51                 new WebDriverWait(driver, 30) { 
     54                new WebDriverWait(driver, 100) { 
    5255                }.until(new ExpectedCondition<Boolean>() { 
    5356                        public Boolean apply(WebDriver driver) { 
     
    6164                String newWindowHandle = afterHandles.iterator().next(); 
    6265                driver.switchTo().window(newWindowHandle); 
     66                driver.switchTo().defaultContent(); 
    6367 
    6468                return PageFactory.initElements(driver, AppointmentEmailPage.class); 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentViewPage.java

    r4962 r5025  
    2222        public static final String DESCRIPTION = "Descrição:"; 
    2323        public static final String LOCAL = "Localização:"; 
    24         public static final String START = "Início Data/Hora:"; 
     24        public static final String START = "Início Data/hora:"; 
    2525        public static final String END = "Data/Hora de término:"; 
    2626        public static final String PRIORITY = "Prioridade:"; 
     
    3939        @FindBy(xpath = "//table[@id='calendar_viewevent_button_left']/tbody/tr/td[2]/nobr/form/div/input[@id='']") 
    4040        private WebElement editSeriesButton; 
     41 
     42        @FindBy(xpath = "//table[@id='calendar_viewevent_button_left']/tbody/tr/td[2]/nobr/form/div/input[@id='']") 
     43        private WebElement readyButton; 
    4144 
    4245        @FindBy(xpath = "//table[@id='calendar_viewevent_button_right']/tbody/tr/td/nobr/form/div/input[@id='']") 
     
    8285                this.removeButton.click(); 
    8386                this.removeAlert(); 
     87        } 
     88 
     89        /** 
     90         *  
     91         */ 
     92        public void ready() { 
     93                this.readyButton.click(); 
    8494        } 
    8595 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/CalendarPage.java

    r4962 r5025  
    174174 
    175175        /** 
     176         * Seleciona um usuario listar seus compromissos. 
     177         *  
     178         * @param user 
     179         *            Usuario selecionado. 
     180         */ 
     181        public void setOwner(String user) { 
     182                super.setComboValue(this.owner, user); 
     183        } 
     184 
     185        /** 
    176186         * Seleciona um mes para filtragem. 
    177187         *  
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/common/HomePage.java

    r4917 r5025  
    2828         */ 
    2929        public void enterMail() { 
    30                 mail.click(); 
     30                super.findAndClickElement(By.xpath("//a/img[@id='expressoMail12id']")); 
    3131                waitForElement(By 
    3232                                .xpath("//table[@id='folders_tbl']/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span")); 
  • devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/common/Page.java

    r4962 r5025  
    5353         */ 
    5454        public void waitForElement(By by) { 
    55                 isDisplayed(this.waitFindElement(by, 10000, 1000)); 
     55                isDisplayed(this.waitFindElement(by, 100000, 1000)); 
    5656        } 
    5757 
     
    200200        } 
    201201 
     202        public List<WebElement> getComboElements(WebElement element) { 
     203                return element.findElements(By.tagName("option")); 
     204        } 
     205 
     206        /** 
     207         * Seleciona todos os valores de um combo. 
     208         *  
     209         * @param element 
     210         */ 
     211        public void selectAllComboValue(WebElement element) { 
     212                List<WebElement> options = element.findElements(By.tagName("option")); 
     213                for (WebElement option : options) { 
     214                        option.setSelected(); 
     215                } 
     216        } 
     217 
     218        /** 
     219         * Verifica se o valor passado esta presente na combo box. 
     220         *  
     221         * @param element 
     222         *            Elemento a verificar. 
     223         * @param value 
     224         *            Valor a verificar. 
     225         * @param select 
     226         *            Se <code>true</code> seleciona o elemento. 
     227         * @return 
     228         */ 
     229        public boolean isValueInCombo(WebElement element, String value, 
     230                        Boolean select) { 
     231 
     232                boolean found = false; 
     233                try { 
     234                        List<WebElement> options = element.findElements(By 
     235                                        .tagName("option")); 
     236                        for (WebElement option : options) { 
     237                                if (option.getText().equals(value)) { 
     238                                        found = true; 
     239                                        if (select) { 
     240                                                option.setSelected(); 
     241                                        } 
     242 
     243                                } 
     244                        } 
     245                } catch (NoSuchElementException nsee) { 
     246                        System.out.println("Warning: ELEMENTO NAO ENCONTRADO!"); 
     247                        found = false; 
     248                } 
     249 
     250                // TODO Rever o tratamento da excecao quando um valor nao for encontrado 
     251                // na combobox. 
     252 
     253                try { 
     254                        throw new Exception("Valor " + value + " não encontrado em " 
     255                                        + element); 
     256                } catch (Exception e) { 
     257                        // TODO Auto-generated catch block 
     258                        e.printStackTrace(); 
     259                } 
     260                return found; 
     261        } 
     262 
    202263        /** 
    203264         * Verifica se um element esta presente na tela. 
Note: See TracChangeset for help on using the changeset viewer.