Page 1 sur 1
[R] _IEGetObjectBy CLASS
Posté : jeu. 27 juin 2013 14:34
par Rancar
Bonjour,
J'ai essayé de créer un petit script qui se connecte sur un site et puis qui clique sur un bouton. Le bouton n'a ni ID, ni NAME, il a juste "CLASS".
J'ai cherché un peu et j'ai trouvé ce sujet sur le forum anglais :
http://www.autoitscript.com/forum/topic ... lass-name/
Le code fonctionne parfaitement mais dès qu'il a cliqué sur ce bouton, le script s'arrête et je ne comprends pas pourquoi...
Voici une partie de mon code :
Code : Tout sélectionner
#include<IE.au3>
$oIE = _IECreate("http://www.google.be")
_IENavigate($oIE,"http://www.xyz.com")
$Pseudo = _IEGetObjByName($oIE, "pseudo")
_IEFormElementSetValue($Pseudo,"xyz")
$MDP = _IEGetObjByName($oIE,"mdp")
_IEFormElementSetValue($MDP,"zyx")
$tags = $oIE.document.connexion.submit()
For $tag in $tags
$class_value = $tag.ClassName("class")
If $class_value = "connexion" Then
_IEAction($class_value,"Click")
EndIf
Next
_IEQuit($oIE)
Merci de votre aide

Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 14:59
par mikell
_IEQuit($oIE) <= !!!
Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 15:30
par Rancar
_IEQuit($oIE) est censé fermer la fenêtre IE mais celle-ci reste toujours ouverte... C'est bien ça le problème ^^
Je peux mettre n'importe quelle commande après (Run, MsgBox, _IENaviguate,...), elle ne sera pas exécuté...
Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 16:05
par mikell
Tu es certainement coincé dans la boucle For et ça mouline
Il a une balise ce bouton, <input> ou autre ?
Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 16:16
par Rancar
Voici son code HTML ^^ :
Code : Tout sélectionner
<a onclick="document.connexion.submit();" class="bouton_connexion"></a>
Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 16:23
par mikell
Effectivement... voyons ce que donne ça
Code : Tout sélectionner
$oElements = _IETagNameAllGetCollection($oIE)
For $oElement In $oElements
If $oElement.classname == "bouton_connexion" Then
_IEAction(oElement, "click")
Exitloop
EndIf
Next
Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 16:34
par Rancar
Parfait *_*
Encore merci pour votre aide Mikell !

Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 16:47
par mikell
Super
Pour faire plus rapide tu peux tenter aussi (sous réserves) : _IETagNameGetCollection($oIE, "a")
Sinon un petit [R] please

Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 16:51
par Rancar
Je viens de rajouter un 2ème clique et ça re-bloque à nouveau =/
Il le connecte, va à la page xyz.com puis blocage.
Il y a-t-il un problème dans le code ? ^^
Code : Tout sélectionner
$Connexion = _IETagNameAllGetCollection($oIE)
$Déconnexion = _IETagNameAllGetCollection($oIE)
For $Connexion In $Connexion
If $Connexion.classname == "bouton_connexion" Then
_IEAction($Connexion, "click")
Exitloop
EndIf
Next
_IENavigate($oIE,"http://www.xyz.com")
For $Déconnexion In $Déconnexion
If $Déconnexion.classname == "bouton_deconnexion" Then
_IEAction($Déconnexion, "click")
Exitloop
EndIf
Next
Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 17:04
par mikell
Oui
Dans les scripts IE, tu ne peux pas déclarer certains trucs à l'avance parce qu'ils concernent la page en cours
Je connais pas tes pages mais a priori ça serait plutôt comme ça
Code : Tout sélectionner
$Connexion = _IETagNameAllGetCollection($oIE)
For $Connexion In $Connexion
If $Connexion.classname == "bouton_connexion" Then
_IEAction($Connexion, "click")
Exitloop
EndIf
Next
_IENavigate($oIE,"http://www.xyz.com")
$Deconnexion = _IETagNameAllGetCollection($oIE)
For $Deconnexion In $Deconnexion
If $Deconnexion.classname == "bouton_deconnexion" Then
_IEAction($Deconnexion, "click")
Exitloop
EndIf
Next
Re: [..] _IEGetObjectfBy CLASS
Posté : jeu. 27 juin 2013 17:07
par Rancar
Ok merci pour l'info

Et merci pour l'aide
Bonne journée =)