Hallo Sven,
hast du vielleicht für den Chrome ein einfachen Beispiel Script, was ich mir bearbeiten kann, also mit dem neuen Aufbau?
Mein aktuelles Script sieht ja wie folgt aus:
AutoIt
#include "wd_helper.au3"
#include "wd_core.au3"
If @LogonDomain <> "domain" Or @LogonDNSDomain <> "domain.INT" Then EXIT ; schließe Script, wenn außerhalb der Domain geöffnet wird
Local $file
Local $sSession = ""
$GoogleChrome64bit = "C:\Program Files\Google\Chrome\Application\chrome.exe"
$GoogleChrome32bit = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
If FileExists($GoogleChrome64bit) Then $file = $GoogleChrome64bit
If FileExists($GoogleChrome32bit) Then $file = $GoogleChrome32bit
If FileExists($file) Then
$google_chrome_version = FileGetVersion($file)
$google_chrome_version_array = StringSplit($google_chrome_version,".")
$webdriver = "chromedriver_" & $google_chrome_version_array[1] & ".exe"
If Not FileExists(@ScriptDir & '\data\'& $webdriver) Then
MsgBox(0,"Info","Google Chromedriver nicht vorhanden." & @CRLF & $webdriver)
Exit
EndIf
Else
MsgBox(0,"Info","Google Chrome in folgenden Pfad nicht vorhanden." & @CRLF & @CRLF & $file)
Exit
EndIf
$url = "https://meine-URL.de"
$user = "User"
$pass = "Passwort"
$_WD_DEBUG = $_WD_DEBUG_None ;set to $_WD_DEBUG_None before compiling.
;Global $_WD_DRIVER
Local $sDesiredCapabilities
Local $iIndex
_WD_UpdateDriver('chrome', @ScriptDir & '\data\') ; Webdriver Download
SetupChrome()
_WD_Startup()
; Hide the WebDriver Console
;_WD_ConsoleVisible(True)
_WD_ConsoleVisible(False)
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Window($sSession, "Maximize", "{}")
_WD_Navigate($sSession, $url)
_WD_LoadWait($sSession)
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='name']")
ConsoleWrite("+ @error = " & @error & @CRLF)
$sElement_user = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='name']")
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='pass']")
ConsoleWrite("+ @error = " & @error & @CRLF)
$sElement_pass = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='pass']")
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sElement_user, 'value',$user)
_WD_ElementAction($sSession, $sElement_pass, 'value',$pass)
Sleep(500)
EndIf
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='loginButton']")
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sElement, 'click')
Sleep(500)
EndIf
_WD_Shutdown()
_WD_DeleteSession($sSession)
Exit
Func SetupChrome()
_WD_Option('Driver', 'data\'& $webdriver)
_WD_Option('Port', 9515)
_WD_Option('DriverParams')
;$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _
;'"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
;'"prefs": {"credentials_enable_service": false} }}}}'
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _
'"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
'"prefs": {"credentials_enable_service": false},' & _
'"args": ["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\chromedriver\\mein-Tool\\"] }}}}'
EndFunc
Alles anzeigen
Wenn ich die DesiredCapabilities ohne --user-data-dir= aufrufe, werden die Cookies nicht gespeichert, deshalb ist der Aufruf hinterlegt.
Gibt es dazu eine andere Lösung? Eben nochmal mit der heise.de Seite getestet.
Gruß Marcel