[R] click sur lien javascript via IE

Aide et conseils concernant AutoIt et ses outils.
Règles du forum
.
Répondre
magicmike
Niveau 1
Niveau 1
Messages : 7
Enregistré le : lun. 20 juin 2016 15:08
Status : Hors ligne

[R] click sur lien javascript via IE

#1

Message par magicmike »

*** Important ***
Bonjour,

Après beaucoup de recherche sur le forum et le forum anglais d'autoit, ne trouvant pas de solution je vous expose mon problème.

Je cherche a cliquer sur un lien javascript, et a analyser le contenu du lien qui s'affiche en dessous après coup. Le click fait développer du texte.

Je n'arrive pas à automatiser ce click sur ce lien via l'include IE.au3.

voici le code javascript :

Code : Tout sélectionner

<DIV class=pharaon-disclosure-panel __listener='<DIV class=pharaon-disclosure-panel><SPAN></SPAN> <H3 tabIndex=0 class=pharaon-disclosure-panel-closed __eventBits="131197">Constitutions (2)</H3> <DIV style="DISPLAY: none"></DIV></DIV>'><SPAN></SPAN>
<H3 tabIndex=0 class=pharaon-disclosure-panel-closed __eventBits="131197">Constitutions (2)</H3>
<DIV class=bloc-ligne-constitution style="DISPLAY: none">
<DIV class=gwt-HTML>
<TABLE class=result-table>
<TBODY>
<TR>

<H3 tabIndex=0 class=pharaon-disclosure-panel-closed __eventBits="131197">Constitutions (2)</H3>
Merci d'avance pour votre aide.
Modifié en dernier par magicmike le mar. 03 janv. 2017 09:25, modifié 1 fois.
magicmike
Niveau 1
Niveau 1
Messages : 7
Enregistré le : lun. 20 juin 2016 15:08
Status : Hors ligne

Re: click sur lien javascript via IE

#2

Message par magicmike »

Bonjour,

Bon finalement avec beaucoup de recherche et d'analyse de différent post un grand merci a : mikell
Que ce soit sur le forum anglais ou français. J'ai résolu mon problème en utilisant de petites astuces.
Je posts mon code si ça peut aider.
Mon site étant spécifique, j'ai enlevé les détails "métier"

Code : Tout sélectionner

#include <Excel.au3>	 					; on inclus les variable excel dans notre code pour pouvoir s'en servir.
#include <AutoItConstants.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
;#RequireAdmin
#include <IE.au3>


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; on appel le site sous IE ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Local $oIE = _IECreate("mon site",1)
Sleep(500)

_IELinkClickByText ($oIE,"Consultation",0,1)  				;;;; on click sur le lien consultation
Sleep(2000)

Local $oDiv = _IEGetObjById($oIE, "searchboxid")					;;;; on cherche lla barre de recherche

_IEFormElementSetValue($oDiv, "texte")					;;; on y implémente le texte a rechercher


sleep (2000)

$oLinks = _IETagNameGetCollection($oIE, "button")				;;;; on click sur le bouton Recherche
For $oLink In $oLinks
    If String($oLink.type) = "button" And String($oLink.value) = "Recherche" Then
          _IEAction($oLink, "click")
         ExitLoop
	EndIf
Next

sleep (2000)


Dim $html = _IEBodyReadText ($oIE)									;;; on lit le code html au format text


$string1 = "Accès"
$Array1 = StringRegExp($html,"(?im)(^.*\b" & $string1 & "\b.*)(?:\r\n?$)",3)		; on y extrait Accès "texte..." que le colle dans un Array (tableau virtuel
$numb = UBound ($Array1)																
																					;;;; ubound : on compte le nombre de référence dans le tableau


$string11 = "La recherche n'a renvoyé aucun résultat."						; on va chercher s'il a une erreur
$Array11 = StringRegExp($html, $string11 ,3)
$numb1 = UBound ($Array11)

;MsgBox(16, "erreur pas d'occurence", $numb)
;_ArrayDisplay($Array11)
if $numb <> 0 then
	_IELinkClickByText ($oIE, $Array1[0], 0 ,1)
ElseIf $numb1 =1 Then
	MsgBox(16, "erreur", "erreur")
	exit
EndIf


;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;   Constitution   ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;



sleep (2000)

	Dim $html1 = _IEBodyReadText ($oIE)


	$string2 = "tesxte"												; on recherche le mot texte dans le code


	$Array2 = StringRegExp($html1, $string2 & "\W.*" ,3)
	$Array3 = StringSplit ($Array2[0], ")",2)
	$Array4 = $Array3[0] & ")"
	;_ArrayDisplay($Array4)
	;MsgBox(0, "Link Info", $Array4)


	$constit0 = "texte (0)"
	$constit1 = "texte (1)"
	$constit2 = "texte(2)"

	if $Array4 = $constit0 Then
		MsgBox(16, "pas de ctexte", $Array4)
	ElseIf $Array4 = $constit1 Then
		MsgBox(0, "1 texte", $Array4)
	ElseIf $Array4 = $constit2 Then
		MsgBox(0, "2 texte", $Array4)
	EndIf

;;;;;;;; on quitte la recherche  pas un click sur un bouton Javascript via son classname

Local $oBtns = _IETagNameGetCollection($oIE, "button")
For $oBtn In $oBtns
    If String($oBtn.classname) = "mon bouton" Then
      _IEAction($oBtn, "click")
   EndIf
Next
Répondre