Bonjour, je ne sais pas si je suis sur le bon forum mais peut-être pourriez-vous m'aider.
J'utilise powershell pour cliquer sur un bouton d'une page web.
Voici une page html toute simple :
1 2 3 4 5 6 7 8 9 10 11
| <!DOCTYPE html>
<html>
<body>
<h2>JavaScript Alert</h2>
<button class="myButtonOn" id="Button002" onclick="goToY(id, this)">Try it</button>
<script>
function goToY(pro, idBouton) {
alert(pro);
}
</script> |
et le code powershell à appliquer pour faire un clic automatique :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Option Explicit
Dim objApp, nIE, oIE, Window, argument
Dim n, counter, monURL
Set objApp = CreateObject("Shell.Application")
Set oIE = Nothing
counter = 0
For Each Window In objApp.Windows
If Window = "Internet Explorer" Then
counter = counter+1
Set oIE = Window
monURL = objApp.Windows(counter).locationUrl
if monURL = "file:///C:/Users/myUsername/Desktop/maPage.html" then
msgbox "ok"
msgbox oIE.Document.getElementById("Button002").innerText
oIE.Document.getElementById("Button002").click
end if
End If
Next |
Comme je suis sur une web application, l'adresse de la pade contient des re-routage :
https://xxxxxxxxxxxxxxxx=https://xxxxxxxxxxxxReroutage.xxxxxproxy=https://xxxxxxxxxxxxxxxxxxxxxxxxx=https://xxxxxxxxxxxxxxxxxx.au
et c'est pour ça que mon code powershell ne marche pas, il n'arrive pas à cibler le bouton.
Pourriez-vous m'aider à résoudre ce problème, svp?
Merci d'avance de votre aide,
Arsène
Partager