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/pages
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • 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.