*** Settings *** Documentation Ressources (librairies, keywords et variables) # Keywords framework Library openmairie.robotframework.Library # Mots-clefs métier Resource app${/}application.robot Resource app${/}fenetre_modale.robot Resource app${/}export.robot *** Variables *** ${SERVER} localhost ${PROJECT_NAME} openresultat ${BROWSER} firefox ${DELAY} 0 ${ADMIN_USER} admin ${ADMIN_PASSWORD} admin ${PROJECT_URL} http://${SERVER}/${PROJECT_NAME}/ ${PATH_BIN_FILES} ${EXECDIR}${/}binary_files${/} ${TITLE} :: openMairie :: openRésultat ${SESSION_COOKIE} openresultat *** Keywords *** For Suite Setup Reload Library openmairie.robotframework.Library Set Suite Variable ${OM_IGNORE_CASE} True # Les keywords définit dans le resources.robot sont prioritaires Set Library Search Order resources Ouvrir le navigateur Tests Setup For Suite Teardown Fermer le navigateur Depuis la page d'accueil [Tags] [Arguments] ${expected_username} ${password} [Documentation] L'objet de ce 'Keyword' est de positionner l'utilisateur ... sur la page de login ou son tableau de bord si on le fait se connecter. # Depuis la page d'accueil du projet, on vérifie si l'utilisateur est # authentifié à l'application en inspectant le titre de la page : soit # nous sommes sur la page de login et l'utilisateur n'est pas authentifié # soit nous sommes sur une autre page et l'utilisateur est authentifié. Go To ${PROJECT_URL} La page ne doit pas contenir d'erreur ${is_not_authenticated} = Run Keyword And Return Status ... Le titre de la page doit être ${OM_TITLE_LOGIN} ${is_authenticated} = Evaluate not ${is_not_authenticated} # On récupère le login de l'utilisateur authentifié pour le comparer à # celui de l'utilisateur attendu. La variable est initialisée à None dans # le cas où aucun utilisateur n'est actuellement authentifié. ${authenticated_username} = Set Variable None ${authenticated_username} = Run Keyword If ${is_authenticated} ... Get Text css=#actions li.action-login # Si l'utilisateur authentifié est celui attendu alors on sort du Keyword. Run Keyword If "${authenticated_username}"=="${expected_username}" ... Return From Keyword L'utilisateur souhaité est déjà connecté. # Si l'utilisateur authentifié n'est pas celui attendu alors on le # déconnecte. # Déconnexion selon la taille de la fenêtre ${window_size}= Get Window Size ${window_width}= Set Variable ${window_size}[0] Run Keyword If ${is_authenticated} and ${window_width} > 769 ... Click Link css=#actions a.actions-logout Run Keyword If ${is_authenticated} and ${window_width} < 769 ... Click Element css=#user-menu-button Run Keyword If ${is_authenticated} and ${window_width} < 769 ... Click Link css=#user-menu a.actions-logout # On se connecte avec l'utilisateur attendu. S'authentifier ${expected_username} ${password} S'authentifier [Tags] [Arguments] ${username}=${ADMIN_USER} ${password}=${ADMIN_PASSWORD} Input Username ${username} Input Password ${password} # Click Element login.action.connect # #Wait Until Keyword Succeeds ${TIMEOUT} ${RETRY_INTERVAL} Element Should Contain css=a.actions-logout Déconnexion # # Déconnexion selon la taille de la fenêtre ${window_size}= Get Window Size ${window_width}= Set Variable ${window_size}[0] Run Keyword If ${window_width} > 769 ... Element Should Contain css=#actions a.actions-logout Déconnexion Run Keyword If ${window_width} < 769 ... Click Element css=#user-menu-button Run Keyword If ${window_width} < 769 ... Element Should Contain css=#user-menu a.actions-logout Déconnexion La page ne doit pas contenir d'erreur Display screen as [Documentation] Permet de redimensionner la fenêtre de test [Arguments] ${screen_type} Run Keyword If '${screen_type}' == 'Desktop' Set Window Size 1920 1080 ... ELSE IF '${screen_type}' == 'Tablet' Set Window Size 900 1024 ... ELSE IF '${screen_type}' == 'Mobile' Set Window Size 375 812 ... ELSE Fail Type d'écran inconnu: ${screen_type} Portlet Action Should Be In Form [Tags] [Arguments] ${obj} ${action} Page Should Contain Element css=#form-container #action-form-${obj}-${action} Portlet Action Should Not Be In Form [Tags] [Arguments] ${obj} ${action} Page Should Not Contain Element css=#form-container #action-form-${obj}-${action} Portlet Action Should Be In SubForm [Tags] [Arguments] ${obj} ${action} Page Should Contain Element css=#sousform-container #action-sousform-${obj}-${action} Portlet Action Should Not Be In SubForm [Tags] [Arguments] ${obj} ${action} Page Should Not Contain Element css=#sousform-container #action-sousform-${obj}-${action}