Hello everybody
This is my first post on this forum and I'd like to congratulate all contributors for the great job over the great UDF. Good job guys !
And now straight to the point. My code looks like this (UTF-8 encoded) :
; launching Chrome:
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log')
Local $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'
_WD_Startup()
$oChr = _WD_CreateSession($sDesiredCapabilities)
$sStatus = _WD_Status()
; main script START ====================================================================
_WD_Navigate($oChr, "https://www.google.pl")
$inp_search = _WD_FindElement($oChr, $_WD_LOCATOR_ByCSSSelector, "input[name='q']")
$inpText = "AB\s=#CD" ; << this is text that is to be entered into input field (password like, so it can contain special characters: [",\,'])
ConsoleWrite("!" & _WD_ElementAction($oChr, $inp_search, "value", $inpText) & @CRLF) ; << this code produces 'missing command parameters' result
Local $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $inp_search & '"}'
ConsoleWrite("! JS Script Execution response: " & _WD_ExecuteScript($oChr, "return arguments[0].setAttribute('value', '" & StringReplace($inpText, "\", "\\\\") & "')", $sJsonElement) & @CRLF) ; << this code is ok, unless ' or " character is entered
_WD_ElementAction($oChr, $inp_search, "clear")
_WD_ElementAction($oChr, $inp_search, "value", "JEZYY") ; << just to be sure, that _WD_ElementAction works with standard alphabet ;)
; main script END ====================================================================
; closing Chrome
_WD_DeleteSession($oChr)
_WD_Shutdown()
So, my question is : how could it be possible to enter the following values into input field - preferably without using JS via _WD_ExecuteScript :
$inpText = "AB\s=#CD" (possible with JS)
$inpText = "AB\s=#C'D"
$inpText = "AB\s=#C""D"
for point 2 I get following error (even after modyfing original string like "AB\\\\s=#C''D" or "AB\\\\s=#C\'D" :
point 3 result with: