#include "wd_helper.au3" #include "wd_capabilities.au3" _Example() Func _Example() # REMARK # This is not functional script # It only shows the concept how to use WebDriver UDF #Region ; initialize webdriver sesion ; you should take care about download/update dirver If $IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, "Question", _ "Do you want to download/update driver ?") Then _WD_UpdateDriver('chrome') EndIf ; specify driver, port and other options _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') ; start the driver _WD_Startup() If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; create capabilites for session _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') Local $sCapabilities = _WD_CapabilitiesGet() ; create session with given Capabilities Local $WD_SESSION = _WD_CreateSession($sCapabilities) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's #EndRegion ; initialize webdriver sesion #Region ; do your's stuff ; navigate to some website Local $sURL = '******' _WD_Navigate($WD_SESSION, $sURL) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; wait for loading process ends _WD_LoadWait($WD_SESSION, 1000) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; for example find element Local $sXPath = "*****" Local $sElement = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath, $sXPath) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; get element text Local $sText = _WD_ElementAction($WD_SESSION, $sElement, 'text') If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ConsoleWrite($sText & @CRLF) ; or click the element _WD_ElementAction($WD_SESSION, $sElement, 'click') If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's #EndRegion ; do your's stuff #Region ; Clean Up ; on the end session should be deleted _WD_DeleteSession($WD_SESSION) If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's ; and driver should be closed _WD_Shutdown() If @error Then Return SetError(@error, @extended, 0) ; always remember to check and handle error's #EndRegion ; Clean Up EndFunc ;==>_Example