DCCD Posted February 27, 2024 Posted February 27, 2024 Hi First time used webdriver udf i use A simple code to open and refresh the page Everything is excellent except for one thing there's a website using CAPTCHA (see the attach pic) The problem when the website is opened via WD -(firefox)-, the CAPTCHA on the website fails! But when I use firefox normally it is confirmed successful hope someone help solve the problem and explains to me why it happened. expandcollapse popup#include <MsgBoxConstants.au3> #include <wd_core.au3> #include <wd_helper.au3> #include "wd_capabilities.au3" ; Here you can specify some browser specific settings... you'll need to research them depending on your browser ; ... or just copy paste someone else's code :D #Region Settings Setup _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) _WD_CapabilitiesAdd('args', '--headless') Global $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' #EndRegion Settings Setup ; You need to initialize some stuff with this UDF _WD_Startup() ; If there is an error setting stuff up, then exit If @error <> $_WD_ERROR_Success Then Exit -1 EndIf Sleep(10000) ; Create a new instance of a browser with some settings you request Global $sSession = _WD_CreateSession($sDesiredCapabilities) ; If there was an error, exit If Not (@error = $_WD_ERROR_Success) Then Exit MsgBox($MB_ICONERROR, "Error: _WD_CreateSession", "Failed to create a Session. Check your desired capabilities.") ; Move to the requested website _WD_Navigate($sSession, "URL") _WD_LoadWait($sSession,500,500,500,500) _WD_Action($sSession, 'REFRESH') MsgBox($MB_ICONINFORMATION, "Navigation completed!", _WD_Action($sSession, 'TITLE')) If @error Then MsgBox($MB_ICONINFORMATION, "Navigation completed!", _WD_LastHTTPResponse()) EndIf ; This removes the browser instance _WD_DeleteSession($sSession) ; And this cleans up some resources _WD_Shutdown() [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
Moderators Solution SmOke_N Posted February 29, 2024 Moderators Solution Posted February 29, 2024 On 2/27/2024 at 1:21 AM, DCCD said: Hi First time used webdriver udf i use A simple code to open and refresh the page Everything is excellent except for one thing there's a website using CAPTCHA (see the attach pic) The problem when the website is opened via WD -(firefox)-, the CAPTCHA on the website fails! But when I use firefox normally it is confirmed successful hope someone help solve the problem and explains to me why it happened. expandcollapse popup#include <MsgBoxConstants.au3> #include <wd_core.au3> #include <wd_helper.au3> #include "wd_capabilities.au3" ; Here you can specify some browser specific settings... you'll need to research them depending on your browser ; ... or just copy paste someone else's code :D #Region Settings Setup _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) _WD_CapabilitiesAdd('args', '--headless') Global $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' #EndRegion Settings Setup ; You need to initialize some stuff with this UDF _WD_Startup() ; If there is an error setting stuff up, then exit If @error <> $_WD_ERROR_Success Then Exit -1 EndIf Sleep(10000) ; Create a new instance of a browser with some settings you request Global $sSession = _WD_CreateSession($sDesiredCapabilities) ; If there was an error, exit If Not (@error = $_WD_ERROR_Success) Then Exit MsgBox($MB_ICONERROR, "Error: _WD_CreateSession", "Failed to create a Session. Check your desired capabilities.") ; Move to the requested website _WD_Navigate($sSession, "URL") _WD_LoadWait($sSession,500,500,500,500) _WD_Action($sSession, 'REFRESH') MsgBox($MB_ICONINFORMATION, "Navigation completed!", _WD_Action($sSession, 'TITLE')) If @error Then MsgBox($MB_ICONINFORMATION, "Navigation completed!", _WD_LastHTTPResponse()) EndIf ; This removes the browser instance _WD_DeleteSession($sSession) ; And this cleans up some resources _WD_Shutdown() Forum Rules Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Recommended Posts