I have been trying to select a field in a page in order to insert a value. I have tried so many tings but am not able to find the elemet on the page. The element is there I can see it. once the page is loaded. I have tried Sleep for 10 seconds, Load wait and every suggestion chat GPt could offer. I have to mention that I have played with the files because I was getting errors in relation to function used in wd-core.au3 so I had to change some function names and all. It could be that me chrome driver is not in synch with the included file versions. As of now. I am getting the error ""Could not find the search button"
#include "JSON.au3"
#include "WinHttp.au3"
#include "wd_core.au3"
#include "wd_helper.au3"
#include "wd_capabilities.au3"
; Setup ChromeDriver
Global $_WD_DRIVER = "C:\Tools\ChromeDriver\chromedriver.exe"
Global $_WD_PORT = 9515
Global $_WD_DRIVER_PARAMS = "--port=9515"
; Start WebDriver
_WD_Startup()
; === Set Capabilities ===
Local $sCaps = '{"capabilities":{"alwaysMatch":{"browserName":"chrome","goog:chromeOptions":{"args":["--start-maximized"]}}}}'
_WD_Option('Capabilities', $sCaps)
; Create Session
Local $sSession = _WD_CreateSession()
If @error Then
MsgBox(16, "Error", "Failed to create session.")
Exit
EndIf
; Navigate to website
_WD_Navigate($sSession, "https://distributionjjcandy.com/account/login")
;Local $sSource = _WD_GetSource($sSession)
;ConsoleWrite($sSource & @CRLF)
;_WD_LoadWait($sSession) ; wait for page to load
Sleep(3000)
Local $jsCode = "return (function() {" & _
"var el = document.querySelector('#input--template--22102333292843__main--customeremail');" & _
"if(el) {return (el.offsetWidth > 0 && el.offsetHeight > 0);} else {return false;}" & _
"})()"
Local $result = _WD_ExecuteScript($sSession, $jsCode)
ConsoleWrite("Visible? " & $result & @CRLF)
; Find and click the search button (by CSS selector)
Local $sElement = _WD_FindElement($sSession, "xpath", "//input[@type='email']")
;Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByLinkText, "Login")
;_WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "a[href='/https/www.autoitscript.com/account/login']", 10000)
;_WD_ElementAction($sSession, $sElement, 'focus')
_WD_SetElementValue($sSession, $sElement, "
[email protected]")
Sleep(1000)
If StringStripWS($sElement, 3) = "" Or StringLower($sElement) = "null" Or StringInStr($sElement, "error") Then
MsgBox(16, "Error", "Could not find the search button.")
Else
_WD_ElementAction($sSession, $sElement, 'click')
EndIf
;Local $sJS = "document.querySelector(""a[href='/https/www.autoitscript.com/account/login']"").click();"
;Local $sResult = _WD_ExecuteScript($sSession, $sJS, "[]")
;ConsoleWrite("JavaScript click result: " & $sResult & @CRLF)
Sleep(3000)
; Close everything
;_WD_DeleteSession($sSession)
;_WD_Shutdown()
ConcoleOutput..A.txt JSON.au3 WinHttp.au3 wd_core.au3 wd_helper.au3 wd_capabilities.au3