def goToModifierEtape(self, urlCourante, stepNum): # recuperation de l'etape a venir en utilisant l'image # Attention, le ctxMenuItemStyle rencontré en premier est celui de l'étape en cours idLink = '<a id=\"dm_route_elements:nxl_feuille_route_instance_listing_' + stepNum + ':nxw_dr_listing_step_actions_' + stepNum + ':titleref\"' htmlEtapeAVenir = extractToken( self.ftest.getBody(), idLink, 'img/icons/bullet_ball_glass_grey_16.png') # recuperation des differents elements de la requete hiddenSourceDocId = extractToken(htmlEtapeAVenir, 'hiddenSourceDocId\').value = \'', '\';') parameterStep = 'dm_route_elements:nxl_feuille_route_instance_listing_' + stepNum + ':nxw_dr_listing_step_actions_' + stepNum + ':nxw_dr_listing_step_actions_' + stepNum + '_edit:editStepListTable:2:documentActionSubviewUpperListLink' self.ftest.post( self.ftest.server_url + urlCourante, params=[ ['stepId', hiddenSourceDocId], # 865380c5-337d-4aa9-827e-7d5f2ae1875b [parameterStep, parameterStep], ['dm_route_elements_SUBMIT', '1'], [ 'javax.faces.ViewState', extractJsfState(self.ftest.getBody()) ] ], description="Aller vers modification de l'étape à venir")
def __extractDossierPath(self, html): dossierpath = extractToken( html, '<li class=\"selected\"><a href=\"' + self.ftest.server_url + '/nxpath/default/case-management/case-root/', '@') if not dossierpath: raise ValueError('No dossier path found in the page') if not dossierpath.startswith('20'): raise ValueError('Invalid dossier path %s' % str(dossierpath)) return dossierpath
def validerDossier(self): fdrParam = self.extractLockTableParam(self.ftest.getBody()) idNode = extractToken(self.ftest.getBody(), 'formFdr:j_id', '\':\'formFdr:j_id') self.ftest.post( self.ftest.server_url + self.urlCourante, params=[ ['formFdr_SUBMIT', '1'], [ 'javax.faces.ViewState', extractJsfState(self.ftest.getBody()) ], ['formFdr:j_id' + idNode, 'formFdr:j_id' + idNode], [ 'formFdr:fdrActionsTable:valider_non_concerne_panelOpenedState', '' ], ], description="Valide le dossier")
def ajoutDonneesBordereau(self, urlCourante): # Il faut conserver le html de la page d'origine pour recuperer des information a l'interieur. # les futur appels a la methode getBody vont retourner le resultat des requetes AJAX. htmlPageOrigine = self.ftest.getBody() idNode = extractToken( htmlPageOrigine, '\'parameters\':{\'bordereauForm:nxl_bordereau_indexation:', '\':\'bordereauForm:nxl_bordereau_indexation:') print idNode # Requete ajax d'ajout de la donnée d'indexation self.ftest.post( self.ftest.server_url + urlCourante, params= [[ 'AJAXREQUEST', 'bordereauForm:nxl_bordereau_indexation:nxw_indexation_rubriques_ajax_region' ], [ 'bordereauForm:nxl_bordereau_donnees_principales:nxw_categorie_acte_bord', '1' ], [ 'bordereauForm:nxl_bordereau_date_publication:nxw_date_publication_fieldInputCurrentDate', '03/2013' ], [ 'bordereauForm:nxl_bordereau_date_signature:nxw_date_signature_fieldInputCurrentDate', '03/2013' ], [ 'bordereauForm:nxl_bordereau_parution:nxw_pour_fourniture_epreuve_fieldInputCurrentDate', '03/2013' ], [ 'bordereauForm:nxl_bordereau_parution:nxw_vecteur_publication_field_selectVecteurs', 'Journal officiel' ], [ 'bordereauForm:nxl_bordereau_parution:nxw_date_precisee_publication_fieldInputCurrentDate', '03/2013' ], [ 'bordereauForm:nxl_bordereau_indexation:nxw_indexation_rubriques_select_index_menu', 'Energie, environnement' ], [ 'bordereauForm:nxl_bordereau_parution:nxw_publication_integrale_ou_extrait_field', '1' ], ['javax.faces.ViewState', extractJsfState(self.ftest.getBody())], [ 'bordereauForm:nxl_bordereau_indexation:' + idNode, 'bordereauForm:nxl_bordereau_indexation:' + idNode ], ['bordereauForm_SUBMIT', '1']], description="AJAX : ajout de la donnée d'indexation du dossier") print "Ajout autres donnees" # ajout données texte + sauvegarde self.ftest.post( self.ftest.server_url + urlCourante, params= [[ 'bordereauForm:nxl_bordereau_donnees_principales:nxw_titre_acte_field', 'titre test funkload ' ], [ 'bordereauForm:nxl_bordereau_donnees_principales:nxw_categorie_acte_bord', '1' ], [ 'bordereauForm:nxl_bordereau_responsable_acte:nxw_nom_resp_dossier_field', 'DUPONT' ], [ 'bordereauForm:nxl_bordereau_responsable_acte:nxw_qualite_resp_dossier_field', 'M' ], [ 'bordereauForm:nxl_bordereau_responsable_acte:nxw_tel_resp_dossier_field', '0102030405' ], [ 'bordereauForm:nxl_bordereau_date_publication:nxw_date_publication_fieldInputCurrentDate', '03/2013' ], [ 'bordereauForm:nxl_bordereau_date_signature:nxw_date_signature_fieldInputCurrentDate', '03/2013' ], [ 'bordereauForm:nxl_bordereau_parution:nxw_pour_fourniture_epreuve_fieldInputCurrentDate', '03/2013' ], [ 'bordereauForm:nxl_bordereau_parution:nxw_vecteur_publication_field_selectVecteurs', 'Journal officiel' ], [ 'bordereauForm:nxl_bordereau_indexation:nxw_indexation_rubriques_select_index_menu', 'Energie, environnement' ], [ 'bordereauForm:nxl_bordereau_parution:nxw_publication_integrale_ou_extrait_field', '1' ], [ 'bordereauForm:nxl_bordereau_parution:nxw_date_precisee_publication_fieldInputCurrentDate', '03/2013' ], ['bordereauForm_SUBMIT', '1'], ['javax.faces.ViewState', extractJsfState(self.ftest.getBody())], [ 'bordereauForm:idSaveBordereauButton', 'bordereauForm:idSaveBordereauButton' ]], description="Ajout et sauvegarde des données du bordereau") return htmlPageOrigine
def ajoutEtapeFDRApresEtapeCourante(self, CommentaireNouvelleEtape, idPoste, deadLine, validationAutomatique, obligatoire, urlCourante): if CommentaireNouvelleEtape == None: CommentaireNouvelleEtape = '' if deadLine == None: deadLine = '' dossierPath = self.__extractDossierPath(self.ftest.getBody()) # recuperation de l'etape courante en utilisant l'image htmlEtapeCourante = extractToken( self.ftest.getBody(), '<li class=\"ctxMenuItemStyle\">', 'img/icons/bullet_ball_glass_yellow_16.png') # recuperation des differents elements de la requete hiddenSourceDocId = extractToken(htmlEtapeCourante, 'hiddenSourceDocId\').value = \'', '\';') #print(hiddenSourceDocId) # ajouter apres self.ftest.post( self.ftest.server_url + urlCourante, params=[ [ 'selectRouteElementsTypeForCreationForm:hiddenSourceDocId', hiddenSourceDocId ], # 865380c5-337d-4aa9-827e-7d5f2ae1875b [ 'selectRouteElementsTypeForCreationForm:hiddenDocOrder', 'after' ], [ 'selectRouteElementsTypeForCreationForm:selectRouteElementsTypePanelOpenedState', '' ], ['selectRouteElementsTypeForCreationForm_SUBMIT', '1'], [ 'javax.faces.ViewState', extractJsfState(self.ftest.getBody()) ], [ 'selectRouteElementsTypeForCreationForm:selectRouteElementsTypeForCreationTable:0:selectRouteElementTypeForCreationCategory:0:selectRouteElementsTypeForCreationCategoryTable:0:createRouteElementLink', 'selectRouteElementsTypeForCreationForm:selectRouteElementsTypeForCreationTable:0:selectRouteElementTypeForCreationCategory:0:selectRouteElementsTypeForCreationCategoryTable:0:createRouteElementLink' ] ], description="AJAX : insertion d'une etape apres l'etape courante") # creation de l'etape self.ftest.post( self.ftest.server_url + "/feuilleroute/create_route_element.faces", params=[ [ 'document_create:nxl_routing_task_detail:routing_task_type', '4' ], # Pour attribution : '4', ... [ 'document_create:nxl_routing_task_detail:nxw_routing_task_distribution_mailbox_nodeId', idPoste ], # 'poste-50000656' ou 'poste-bureau-des-cabinets' [ 'document_create:nxl_routing_task_detail:nxw_routing_task_description', CommentaireNouvelleEtape ], # 'Commentaire nouvelle \xc3\xa9tape.' [ 'document_create:nxl_routing_task_detail:nxw_routing_task_deadline:nxw_routing_task_deadline_from', deadLine ], [ 'document_create:nxl_routing_task_detail:nxw_routing_task_automatic_validation', validationAutomatique ], [ 'document_create:nxl_routing_task_detail:nxw_routing_task_obligatoire_ministere', obligatoire ], ['parentDocumentPath', dossierPath], ['document_create:button_create', 'Cr\xc3\xa9er'], # bouton de validation ['document_create_SUBMIT', '1'], [ 'javax.faces.ViewState', extractJsfState(self.ftest.getBody()) ] ], description="Creation de l'etape de la feuille de route")
def ajouterFichierParapheur(self, urlCourante, filepath): #, htmlPageOrigine): # verification que le fichier existe if not os.path.exists(filepath): print('File not found : ' + filepath) # Il faut conserver le html de la page d'origine pour recuperer des information a l'interieur. # les futur appels a la methode getBody vont retourner le resultat des requetes AJAX. htmlPageOrigine = self.ftest.getBody() # selection du répertoire Acte Intégral. ''' exemple de requete : self.post(server_url + urlCourante, params=[ ['AJAXREQUEST', 'document_properties:documentViewRegion'], ['document_properties:parapheurTree:1::parapheurFolderVideDocAjoutableNodeExpanded', 'true'], ['document_properties:parapheurTree:2::parapheurFolderVideDocAjoutableNodeExpanded', 'true'], ['document_properties:parapheurTree:3::parapheurFolderVideDocAjoutableNodeExpanded', 'true'], ['document_properties:parapheurTree:input', 'document_properties:parapheurTree:1::parapheurFolderVideDocAjoutable'], ['document_properties_SUBMIT', '1'], ['javax.faces.ViewState', extractJsfState(self.ftest.getBody())], ['document_properties:parapheurTree:selectedNode', 'document_properties:parapheurTree:1::parapheurFolderVideDocAjoutable']], description="Post /solonepg/..._view.faces") ''' idNode = extractToken(self.ftest.getBody(), 'document_properties:parapheurTree:1::', '\"><tbody>') self.ftest.post( self.ftest.server_url + urlCourante, params= [['AJAXREQUEST', 'document_properties:documentViewRegion'], [ 'document_properties:parapheurTree:1::parapheurFolderVideDocAjoutableNodeExpanded', 'true' ], [ 'document_properties:parapheurTree:2::parapheurFolderVideDocAjoutableNodeExpanded', 'true' ], [ 'document_properties:parapheurTree:3::parapheurFolderVideDocAjoutableNodeExpanded', 'true' ], [ 'document_properties:parapheurTree:input', 'document_properties:parapheurTree:1::parapheurFolderVideDocAjoutable' ], ['document_properties_SUBMIT', '1'], ['javax.faces.ViewState', extractJsfState(self.ftest.getBody())], [ 'document_properties:parapheurTree:selectedNode', 'document_properties:parapheurTree:1::parapheurFolderVideDocAjoutable' ]], description="AJAX : Select bouton Acte intégral") # Clic sur 'Ajouter document' ''' exemple de requete : self.post(server_url + urlCourante, params=[ ['AJAXREQUEST', 'document_properties:documentViewRegion'], ['document_properties:parapheurTree:1::parapheurFolderVideDocAjoutableNodeExpanded, 'true'], ['document_properties:parapheurTree:2::parapheurFolderVideDocAjoutableNodeExpanded', 'true'], ['document_properties:parapheurTree:3::parapheurFolderVideDocAjoutableNodeExpanded', 'true'], ['document_properties:parapheurTree:input', 'document_properties:parapheurTree:1::parapheurFolderVideDocAjoutable'], ['document_properties_SUBMIT', '1'], ['javax.faces.ViewState', extractJsfState(self.ftest.getBody())], ['SelectedNodeId', '9881bbf1-7c04-42b8-90e9-9f5f37bdf7be'], ['SelectedNodeType', 'ParapheurFolder'], ['document_properties:j_id1101', 'document_properties:j_id1101'], ['ajaxSingle', 'document_properties:j_id1101']], description="Post /solonepg/..._view.faces") ''' # idNode a la même valeur que dans la requete precedente #idDocumentProperties = extractToken(htmlPageOrigine, 'document_properties:j_id', '\',\'parameters') SelectedNodeId = extractToken(htmlPageOrigine, "'show',{'id': '", "', 'type':") #print(SelectedNodeId) SelectedNodeId = SelectedNodeId.replace('\\x2D', '-') # print(SelectedNodeId) self.ftest.post( self.ftest.server_url + urlCourante, params= [['AJAXREQUEST', 'document_properties:documentViewRegion'], [ 'document_properties:parapheurTree:1::parapheurFolderVideDocAjoutableNodeExpanded', 'true' ], [ 'document_properties:parapheurTree:2::parapheurFolderVideDocAjoutableNodeExpanded', 'true' ], [ 'document_properties:parapheurTree:3::parapheurFolderVideDocAjoutableNodeExpanded', 'true' ], [ 'document_properties:parapheurTree:input', 'document_properties:parapheurTree:1::parapheurFolderVideDocAjoutable' ], ['document_properties_SUBMIT', '1'], ['javax.faces.ViewState', extractJsfState(self.ftest.getBody())], ['SelectedNodeId', SelectedNodeId], ['SelectedNodeType', 'ParapheurFolder'], ['document_properties:j_id1787', 'document_properties:j_id1787'], ['ajaxSingle', 'document_properties:j_id1787']], description="AJAX : Ajouter document'") # ajout du fichier #print("### Upload du fichier : " + filepath) filename = os.path.basename(filepath) # rich face random uid upload_uid = str(random.random()) #Attention, ne pas descendre les parametres passés dans la string dans le tableau self.ftest.post( self.ftest.server_url + urlCourante + "?_richfaces_upload_uid=" + upload_uid + "&editFileForm:uploadParapheurFiles=editFileForm:uploadParapheurFiles&_richfaces_upload_file_indicator=true&AJAXREQUEST=editFileRegion", params=[ ['editFileForm:uploadParapheurFiles:file', Upload(filepath)], # adresse du fichier ['editFileForm_SUBMIT', '1'], [ 'javax.faces.ViewState', extractJsfState(self.ftest.getBody()) ] ], description="AJAX : Upload du fichier") self.ftest.post( self.ftest.server_url + urlCourante, params=[['AJAXREQUEST', 'editFileRegion'], ['editFileForm:uploadParapheurFiles:file', ''], ['editFileForm_SUBMIT', '1'], [ 'javax.faces.ViewState', extractJsfState(self.ftest.getBody()) ], ['ajaxSingle', 'editFileForm:uploadParapheurFiles'], [ 'editFileForm:uploadParapheurFiles', 'editFileForm:uploadParapheurFiles' ], ['AJAX:EVENTS_COUNT', '1']], description= "AJAX : Requete post-upload : Reaffichage de la boite de telechargement." ) idEditForm = extractToken(htmlPageOrigine, '\"editFileForm:j_id', '\"') self.ftest.post(self.ftest.server_url + urlCourante, params=[['AJAXREQUEST', 'editFileRegion'], ['editFileForm:uploadParapheurFiles:file', ''], ['editFileForm_SUBMIT', '1'], [ 'javax.faces.ViewState', extractJsfState(self.ftest.getBody()) ], [ 'editFileForm:j_id' + idEditForm, 'editFileForm:j_id' + idEditForm ], ['AJAX:EVENTS_COUNT', '1']], description="AJAX prévalidation upload") #Validation de l'upload du fichier self.ftest.post( self.ftest.server_url + urlCourante, params=[['AJAXREQUEST', 'editFileRegion'], ['editFileForm:uploadParapheurFiles:file', ''], ['editFileForm_SUBMIT', '1'], [ 'javax.faces.ViewState', extractJsfState(self.ftest.getBody()) ], ['ajaxSingle', 'editFileForm:editFileButtonText'], [ 'editFileForm:editFileButtonText', 'editFileForm:editFileButtonText' ], ['AJAX:EVENTS_COUNT', '1']], description="AJAX : Validation definitive de l'upload") # les reponses AJAX ne permettent pas de savoir si le document a bien ete uploade # Verification que le dossier dispose bien d'un document ayant le nom de celui que l'on vient d'ajouter. # Attention, si on ajoute 2 documents avec le meme nom, un seul d'entre eux est bien uploade. self.ftest.assert_( '\'name\': \'' + filename + '\', \'type\': \'ParapheurFichier\'' in self.ftest.getBody()) return htmlPageOrigine
def __extractNavigation(self, imgname): html = self.ftest.getBody() id = extractToken(html, imgname + '" name="', '" alt') return id