Hallo,
ich hab das Problem, das ich mit _ffxpath nicht mehr arbeiten kann, sobald ich ein formular abgeschickt habe.
Also die erste Seite (wo auch das Formular ist) kann ich mit _ffxpath arbeiten.
Sobald ich aber das formular mittels _ffclick abschicke und die zweite Seite erscheint, geht mit _ffxpath nix mehr.
Es scheint als ob _ffxpath sich immer noch auf der ersten Seite befindet. D.h. _ffxpath findet HTML-Elemente, die nur auf der ersten Seite zu finden waren.
Hier mal ein Beispiel Script:
Es werden 2 Seite nach dem String 'Mein String' mittels xpath durchsucht.
Sollte auf der ersten Seite der String nicht gefunden werden,
so soll auf den Button geklickt werden.
Danach sollte der String 'Mein String' gefunden werden. (tuts aber nicht )
Beispiel Script
;--------------------------------------------------
; Include
;--------------------------------------------------
#include <FF.au3>
;--------------------------------------------------
;--------------------------------------------------
; Variablen
;--------------------------------------------------
$dateiname = "1.html"
;$dateiname = "2.html" ; Entferne am Anfang den Kommentar um zu sehen, dass xpath eigentlich funktioniert.
;--------------------------------------------------
;--------------------------------------------------
; Erzeugt zum testen 2 HTML-Dateien
;--------------------------------------------------
$file = FileOpen("1.html", 2)
If $file = -1 Then
MsgBox(64, "Error", "Unable to open file.")
Exit
EndIf
FileWrite($file, '<html><body><div id="text">Kein String</div><form action="2.html" method="post"><input type="submit" id="seite2" value="Zu Seite 2"></form></body></html>')
FileClose($file)
$file = FileOpen("2.html", 2)
If $file = -1 Then
MsgBox(64, "Error", "Unable to open file.")
Exit
EndIf
FileWrite($file, '<html><body><div id="text">Mein String</div><form action="1.html" method="post"><input type="submit" id="seite1" value="Zu Seite 1"></form></body></html>')
FileClose($file)
;--------------------------------------------------
;--------------------------------------------------
; Starte FF und lade die Seite
;--------------------------------------------------
$file = FileGetShortName(@WorkingDir) & "\" & $dateiname
_FFStart("file:///" & StringReplace($file, "\", "/", 0, 2))
MsgBox(64, "Sleep()", "In 3 Sekunden gehts weiter.", 3)
;--------------------------------------------------
;--------------------------------------------------
; Im 1. Durchlauf wird 'Mein String' nicht gefunden,
; stattdessen klicke auf den Form-Button
; Im 2. Durchlauf sollte 'Mein String' gefunden werden.
;--------------------------------------------------
$i = 1
$abbruch = 0
While 1
$xpath = "//*[contains(.,'Mein String')]"
If Int(_FFXPath($xpath, Default, 3)) Then ExitLoop
$xpath = "//input[@id='seite2']"
If Int(_FFXPath($xpath, Default, 3)) Then
_FFClick(_FFXPath($xpath))
MsgBox(64, "Schleifendurchlauf: " & $i, "Dieser If-Zweig sollte eigentlich nur einmal durchlaufen werden.")
EndIf
;While Abbruch Code
$i += 1
If $i > 3 Then
$abbruch = 1
ExitLoop
EndIf
WEnd
;--------------------------------------------------
; Das Ergebnis
;--------------------------------------------------
If Not $abbruch Then
MsgBox(0, "OK", "Mein String wurde gefunden!")
Else
MsgBox(0, "ERROR", "Mein String wurde NICHT gefundnen!")
EndIf
;--------------------------------------------------
;--------------------------------------------------
; Beende FF und Verlasse das Programm
;--------------------------------------------------
_FFQuit()
Exit
;--------------------------------------------------
Konsolenausgabe
__FFStartProcess: ""D:\Programme\Mozilla Firefox\firefox.exe" -new-window "file:///D:/1.html" -repl 4242
_FFConnect: OS: WIN_XP WIN32_NT 2600 Service Pack 3
_FFConnect: AutoIt: 3.3.6.1
_FFConnect: FF.au3: 0.6.0.1b-5
_FFConnect: IP: 127.0.0.1
_FFConnect: Port: 4242
_FFConnect: Delay: 2ms
_FFConnect: Socket: 1648
_FFConnect: Browser: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 ( .NET CLR 3.5.30729; .NET4.0E)
__FFSendJavaScripts: Sending functions to FireFox .......... done
_FFLoadWait: . loaded in 90ms
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//*[contains(.,'Mein String')]",FFau3.WCD,null,XPathResult.BOOLEAN_TYPE,null).booleanValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: 0
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//input[@id='seite2']",FFau3.WCD,null,XPathResult.BOOLEAN_TYPE,null).booleanValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: 1
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//input[@id='seite2']",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: [object XPCNativeWrapper [object HTMLInputElement]]
__FFSend: try{FFau3.simulateEvent(FFau3.xpath,'MouseEvents','click');}catch(e){'_FFCmd_Err';};
__FFRecv: 1
_FFLoadWait: .. loaded in 310ms
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//*[contains(.,'Mein String')]",FFau3.WCD,null,XPathResult.BOOLEAN_TYPE,null).booleanValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: 0
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//input[@id='seite2']",FFau3.WCD,null,XPathResult.BOOLEAN_TYPE,null).booleanValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: 1
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//input[@id='seite2']",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: [object XPCNativeWrapper [object HTMLInputElement]] — {dispatchEvent: function() {…}, parentNode: {…}, nodeType: 1, getAttributeNS: function() {…}}
__FFSend: try{FFau3.simulateEvent(FFau3.xpath,'MouseEvents','click');}catch(e){'_FFCmd_Err';};
__FFRecv: 1
_FFLoadWait: . loaded in 14ms
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//*[contains(.,'Mein String')]",FFau3.WCD,null,XPathResult.BOOLEAN_TYPE,null).booleanValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: 0
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//input[@id='seite2']",FFau3.WCD,null,XPathResult.BOOLEAN_TYPE,null).booleanValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: 1
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//input[@id='seite2']",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: [object XPCNativeWrapper [object HTMLInputElement]] — {dispatchEvent: function() {…}, parentNode: {…}, nodeType: 1, getAttributeNS: function() {…}}
__FFSend: try{FFau3.simulateEvent(FFau3.xpath,'MouseEvents','click');}catch(e){'_FFCmd_Err';};
__FFRecv: 1
_FFLoadWait: . loaded in 15ms
__FFQuit: Closing FireFox ...
+>02:33:27 AutoIT3.exe ended.rc:0
>Exit code: 0 Time: 19.474
Alles anzeigen
Was kann ich tun, damits mit _ffxpath doch so läuft wie gedacht?
Gruß
CD