Hallo Code4Fun,
das heißt du automatisiertst die Eingaben in der Firefox Oberfläche einer bestimmten Website?
Wenn ja, kannst du dieses sicherlich mit dem ChromeDriver (WebDriver) umsetzen.
Hier mal eine Beispiel für Google Chrome -> für Firefox muss man intern den geckodriver nutzen.
"Paypal Login (ohne Funktionsgarantie )
AutoIt
#include "wd_helper.au3"
#include "wd_core.au3"
#include <MsgBoxConstants.au3>
; webdriver_versionsnummer.exe liegt im Sciptdir, im Unterordner "data" (Beispiel : chromedriver_104.exe)
$user = "" ;User
$pass = "" ;Passwort
$file = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
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://www.paypal.com/de/signin"
$_WD_DEBUG = $_WD_DEBUG_None ;set to $_WD_DEBUG_None before compiling.?
;Global $_WD_DRIVER
Local $sDesiredCapabilities
Local $iIndex
SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, $url)
MsgBox(0,"Info","Bitte eventuelle Captcha lösen",3)
Sleep(3000)
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='login_email']")
ConsoleWrite("+ @error = " & @error & @CRLF)
$sElement_mail = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='login_email']")
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='login_password']")
ConsoleWrite("+ @error = " & @error & @CRLF)
$sElement_pass = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='login_password']")
If @error = $_WD_ERROR_Success Then
;set value to ""
_WD_ElementAction($sSession, $sElement_Mail, "clear")
Sleep(500)
_WD_ElementAction($sSession, $sElement_mail, 'value',$user)
EndIf
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sElement_pass, 'value',$pass)
EndIf
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="btnLogin"]')
ConsoleWrite("+ @error = " & @error & @CRLF)
$sElement_login_btn = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="btnLogin"]')
If @error = $_WD_ERROR_Success Then
_WD_ElementAction($sSession, $sElement_login_btn, 'click')
Sleep(1000)
EndIf
;_WD_DeleteSession($sSession)
_WD_Shutdown()
Exit
Func SetupChrome()
;_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Driver', 'data\'& $webdriver) ; webdriver.exe liegt im Sciptdir, im Unterordner "data"
_WD_Option('Port', 9515)
;_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
_WD_Option('DriverParams')
;~ $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _
;~ '"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
;~ '"prefs": {"credentials_enable_service": false},' & _
;~ '"args": ["start-maximized"] }}}}'
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _
'"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
'"prefs": {"credentials_enable_service": false},' & _
'"args": ["--start-maximized" ,"--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\chromedriver\\FTI-Paypal\\", "--profile-directory=Default"] }}}}'
EndFunc
Alles anzeigen
@Moombas: Das ist auch eine gute Möglichkeit um die Daten zu verarbeiten. Daran hatte ich grad nicht gedacht
obwohl ich das ja ähnlich bei meinem LimeSurvey Script umgesetzt habe.
Gruß gmmg