ich hab mal wieder ein Problem.
Hab versucht mit ChroPath und SelectorsHub den xPath auszulesen.
Komme da nicht weiter.
Mal läuft das Script durch, meistens bleibt es irgendwo stehen.
- vielleicht sind die xPath falsch oder es liegt an den iframes oder svg.
- im headless Mode läuft es überhaupt nicht.
- gibt es eine möglichkeit das besser abzusichern - Hatte schon eine While 1 Schleife um jeden Punkt gebaut.
- kann man den Zugriff schneller machen - oder läßt Mydrive nicht mehr zu.
Vielleicht kann mal einer drüber gucken und mir entsprechende Tips geben.
#include <MsgBoxConstants.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
;Dos Console für Fehlerermitlung
$_WD_DEBUG = $_WD_DEBUG_Info ; ==> Dos Fehlerconsole an [<>]
;$_WD_DEBUG = $_WD_DEBUG_None ; ==> Dos Fehlerconsole aus [<>]
;*********************************************************
; Path zum Geckodriver
;FileChangeDir ( "C:\Webdrv22\au3WebDriver-0.11.0")
FileChangeDir ("C:\Users\xx2\Desktop\Tourenplanung Jaeckel\WebDrv\au3WebDriver-0.11.0\")
; TomTom MyDrive Link ;*
;Global $URLMyDr = ("https://mydrive.tomtom.com/de_de")
Global $URLMyDr = ("https://mydrive.tomtom.com/de_de/#mode=viewport+viewport" _
& "=49.9071,7.8184,13,0,-0+ver=3")
Global $t = 200 ; Werte für Sleep
Global $mail = "xxyy@gmx.de"
Global $pass = "11111111"
Global $HanName = "Landhotel"
Global $HanAdress = "Westfälische Str. 52 57368 Lennestadt"
Local $sDesiredCapabilities, $sSession
SetupGecko()
_WD_Startup( )
Sleep ($t)
Global $sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, $URLMyDr)
Sleep (2000)
login_MyDrive()
Gecko_beenden()
func login_Mydrive()
; ==> Cookie Button **************************
Local $xPath = "//*[@id='cookie_banner_allow_button']"
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
sleep ($t)
_WD_ElementAction($sSession, $sButton, 'click')
If @error = $_WD_ERROR_Success Then
ConsoleWrite("Fehler -- Cookie Button" & @CRLF)
;MsgBox(0,"Fehler -- Cookie Button","")
Endif
;*********************************************************************************************************
; ==> Click Anmelde Button *****************************************************************
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//button[contains(text(),'Anmelden')]" )
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,"//button[contains(text(),'Anmelden')]" )
sleep ($t)
_WD_ElementAction($sSession, $sButton, 'click')
If @error = $_WD_ERROR_Success Then
ConsoleWrite("Fehler -- Anmelde Button" & @CRLF)
;MsgBox(0,"Fehler -- Anmelde Button","")
Endif
;*******************************************************************************************************
;==> iframe Login suchen ********************************************************************
Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='iFrameResizer0']")
sleep ($t)
_WD_FrameEnter($sSession, $sElement)
If @error = $_WD_ERROR_Success Then
ConsoleWrite("Fehler -- iframe Login suchen" & @CRLF)
;MsgBox(0,"Fehler -- iframe Login suchen","")
Endif
;********************************************************************************************************
; ==> Emailadresse eintragen *********************************************************
Local $xPath = "//input[@type='text']"
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
Local $sElement_mail = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
sleep ($t)
_WD_ElementAction($sSession, $sElement_mail, 'value',$mail)
If @error = $_WD_ERROR_Success Then
ConsoleWrite("Fehler -- Emailadresse eintragen" & @CRLF)
;MsgBox(0,"Fehler -- Emailadresse eintragen","")
Endif
;*******************************************************************************************************
; ==> Passwort eintragen *********************************************************
Local $xPath = "//input[@type='password']"
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
Local $sElement_pass = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
sleep ($t)
_WD_ElementAction($sSession, $sElement_pass, 'value',$pass)
If @error = $_WD_ERROR_Success Then
ConsoleWrite("Fehler -- Passwort eintragen" & @CRLF)
;MsgBox(0,"Fehler -- Passwort eintragen","")
Endif
;*****************************************************************************************************
; ==> Click Login button ***************************************************************************
Local $xPath = "//*[@id='loginButton']"
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
sleep ($t)
_WD_ElementAction($sSession, $sButton, 'click')
If @error = $_WD_ERROR_Success Then
ConsoleWrite("Fehler -- Login button " & @CRLF)
;MsgBox(0,"Fehler -- Login button ","")
Endif
;*********************************************************************************************************
; ==> iframe zurück setzen******************************************************************************************
_WD_Navigate($sSession, $URLMyDr) ; https://mydrive.tomtom.com/de
sleep ($t)
If @error = $_WD_ERROR_Success Then
ConsoleWrite("Fehler -- iframe zurück setzen" & @CRLF)
MsgBox(0,"Fehler -- iframe zurück setzen","")
Endif
;********************************************************************************************************************
; ==> Click Button "Meine Orte" anklicken **************************************
Local $xPath = "//div[@id='my_places_menu_item']"
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath)
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sButton, 'click')
ConsoleWrite("Fehler -- Meine Orte" & @CRLF)
;MsgBox(0,"Fehler -- Meine Orte","")
Endif
sleep ($t)
;*******************************************************************************************************
; ==> Button "Favoriten" Button ******************************
$xPath = "//span[@id='my_places_favourites']"
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sButton, 'click')
ConsoleWrite("Fehler -- Favoriten Button " & @CRLF)
;MsgBox(0,"Fehler -- Favoriten Button ","")
Endif
sleep($t)
;*******************************************************************************************************
Sleep(800) ; kurze Pause
;*******************************************************************************************************
; ==> Button "Neuen Ort hinzufügen" ******************************
Local $xPath = "/html[1]/body[1]/div[2]/div[4]/div[1]/div[4]/div[2]/div[1]/div[1]/div[2]/div[4]/div[1]/div[1]"
;Local $xPath = "//div[@id='favourites_view_add_favourite_button']"
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sButton, 'click')
ConsoleWrite("Fehler -- Neuen Ort hinzufügen" & @CRLF)
;MsgBox(0,"Fehler -- Neuen Ort hinzufügen","")
Endif
sleep ($t)
;*******************************************************************************************************
; ==> "Adresse" eintragen *********************************************************
Local $xPath = "//input[@id='favourite_location_search_input_box']"
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
Local $sElement_HanAdress = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sElement_HanAdress, 'value',$HanAdress)
ConsoleWrite("Fehler -- Adresse eintragen" & @CRLF)
;MsgBox(0,"Fehler -- Adresse" eintragen","")
Endif
sleep ($t)
;*******************************************************************************************************
;; ==> "Nummer und Name" eintragen ********************************************************
Local $xPath = "/html[1]/body[1]/div[2]/div[4]/div[1]/div[4]/input[1]"
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
Local $sElement_HanName = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sElement_HanName, 'value',$HanName )
ConsoleWrite("Fehler -- Nummer und Name eintragen " & @CRLF)
;MsgBox(0,"Fehler -- Nummer und Name eintragen ","")
Endif
sleep ($t)
;*******************************************************************************************************
;; ==> "Adresse bestätigen" ohne Button *********************************************************
Local $xPath = "//*[@id='favourite_search_list_item_address_0']"
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sButton, 'click')
ConsoleWrite("Fehler -- Adresse bestätigen" & @CRLF)
;MsgBox(0,"Fehler -- Adresse bestätigen","")
Endif
sleep ($t)
;*******************************************************************************************************
; ==> Button Fertig ******************************
Local $xPath = "//button[@id='favourite_add_done_btn']"
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sButton, 'click')
ConsoleWrite("Fehler -- Button Fertig " & @CRLF)
;MsgBox(0,"Fehler -- Button Fertig","")
Endif
Sleep($t)
;*******************************************************************************************************
MsgBox(0,"Fehler Box","Adresse löschen")
; ==> Adresse löschen ******************************
Local $xPath = "/html[1]/body[1]/div[2]/div[4]/div[1]/div[4]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[3]/div[1]/div[4]/div[1]/*[name()='svg'][1]/*[name()='path'][1]"
;Local $xPath = "/html/body/div[2]/div[4]/div/div[4]/div[2]/div[1]/div/div[1]/div/div/div[3]/div/div[4]/div/svg"
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $xPath )
_WD_ElementAction($sSession, $sButton, 'click')
If @error = $_WD_ERROR_Success Then
;_WD_ElementAction($sSession, $sButton, 'click')
ConsoleWrite("Fehler -- Adresse löschen " & @CRLF)
;MsgBox(0,"Fehler -- Adresse löschen","")
Endif
Sleep($t)
;*******************************************************************************************************
EndFunc ;==> login_Mydrive()
Func SetupGecko()
_WD_Option("Driver", "C:\Users\xx2\Desktop\Tourenplanung Jaeckel\WebDrv\au3WebDriver-0.11.0\geckodriver.exe")
_WD_Option ( 'DriverParams' , '--log trace --marionette-port 2828' )
_WD_Option('Port', 4444)
; ==> neues Profil anlegen
; im sichtbaren Modus ausführen
Global $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}'
; unsichtbar ausfführen
;~ Global $sDesiredCapabilities = _
;~ '{' & _
;~ ' "capabilities": {' & _
;~ ' "alwaysMatch": {' & _
;~ ' "browserName": "firefox",' & _
;~ ' "acceptInsecureCerts": true,' & _
;~ ' "moz:firefoxOptions": {' & _
;~ ' "args": [' & _
;~ ' "--headless"' & _
;~ ' ]' & _
;~ ' }' & _
;~ ' }' & _
;~ ' }' & _
;~ '}'
EndFunc ;==>SetupGecko
Func Gecko_beenden()
MsgBox(0,"","") ; hält Browser an
_WD_DeleteSession($sSession)
_WD_Shutdown()
EndFunc ; ==> Gecko_beenden()
Alles anzeigen