Jump to content

WD Web Driver problem with huge string size, passing it to chrome


Go to solution Solved by Nine,

Recommended Posts

Posted (edited)

I must send a huge string file with WD to JS var on chrome.
Up to now it worked well, but now the file reached more than 31MB size (and it's growing...): 31,4 MB (33.000.029 bytes) and it gives error.

I made this reproducible script to simulate my file:

#include "au3WebDriver-1.11/wd_helper.au3"
#include "au3WebDriver-1.11/wd_core.au3" 
#include "au3WebDriver-1.11/wd_capabilities.au3" 

#AutoIt3Wrapper_UseX64=Y  

$_WD_DEBUG =  $_WD_DEBUG_Info 
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', _WD_GetFreePort() )
Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT
_WD_Option('DriverParams', $sDriverParams)

_WD_Startup()
global $sSession = _WD_CreateSession()  

global $sStr = ''
global $fileName = "ko.txt"     ;********** use this line if you want to see the ERROR
;~  $fileName = "ok.txt"        ;********** use this line if you want to test a slighlty less string size that WORKS

;********** generate string size:
;~ 32.000.000 bytes OK  31.251 KB filesize
;~ 33.000.000 bytes KO  32.227 KB filesize
for $i=0 to 365000 ; string rows
    $sStr &= stringformat("%014d",$i) & "|" &  _MakeString(6,12) & "|USD|" & _MakeString(6,23) & "|" & _MakeString(8,25) & "|" &  "|BROAD|2|0|0||0|||0|0|0|0|0|" & @crlf
    if Mod($i, 5000) = 0 then ConsoleWrite(".")
    if Mod($i, 50000) = 0 then ConsoleWrite(@crlf & $i)
    if ($fileName = "ok.txt" And StringLen($sStr) >= 32000000) Or ($fileName = "ko.txt" And StringLen($sStr) >= 33000000) then ExitLoop
Next


ConsoleWrite( @crlf &  $i & "_len:_" & StringLen($sStr) & @CRLF)
; **** if you want to save the file:
;~ local $hFile = FileOpen($fileName, 2 )
;~ FileWrite($hFile, $sStr)
;~ FileClose($hFile)
ConsoleWrite( StringLeft($sStr,500) &  @CRLF) ; test example string


_WD_ExecuteScript($sSession, 'var sTemp = "";' ) 
_WD_ExecuteScript($sSession, 'sTemp = `' & $sStr & '`;' ) 
ConsoleWrite(@error & "___" & @extended & @CRLF)
MsgBox(0,'','sent?')

Func _MakeString($min, $max)
    Local $aSplit = StringSplit(' abcdefghijklmnopqrstuvwxyz0123456789', '')
    Local $sHoldString = ''
    For $iCC = 1 To Random($min, $max, 1)
        $sHoldString &= $aSplit[Random(1, 36, 1)]
    Next
    Return $sHoldString
EndFunc

and this is Scite log on the "ko.txt" string size:

  Quote

Starting process #6
"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "d:\Surface7\PROG_analisi\Test_HUGEstring_WD.au3" [PID 7104]
+>11:45:11 Starting AutoIt3Wrapper (19.1127.1402.0} from:Code.exe (1.82.2.0)  Keyboard:00000410  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0410)
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:d:\Surface7\PROG_analisi\Test_HUGEstring_WD.au3
+>11:45:12 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "d:\Surface7\PROG_analisi\Test_HUGEstring_WD.au3"  /errorstdout
+>Setting Hotkeys...--> Press Ctrl+Alt+Pausebreak to Restart or Ctrl+Pausebreak to Stop.
_WD_Option  Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe
_WD_GetFreePort  Success [0 / 64001] : Parameters:   MinPort=Default   MaxPort=Default
_WD_Option  Success [0] : Parameters:   Option=Port   Value=64001
_WD_Option  Success [0] : Parameters:   Option=DriverParams   Value=--verbose --log trace --port=64001
_WD_GetFreePort  Success [0 / 64001] : Parameters:   MinPort=64001   MaxPort=Default
_WD_IsLatestRelease  Success [0] : False
_WD_Startup: OS:    WIN_10 X64 19045
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: Webdriver UDF:    1.1.1 (Update available)
_WD_Startup: WinHTTP:    1.6.4.2
_WD_Startup: Driver:    chromedriver.exe (64 Bit)
_WD_Startup: Params:    --verbose --log trace --port=64001
_WD_Startup: Port:    64001
_WD_Startup: Command:    "chromedriver.exe" --verbose --log trace --port=64001
_WD_Startup  Success [0]
__WD_Post  Success [0] : HTTP status = 200
_WD_CreateSession  Success [0] : 4f40508021e21e7a6eaed7281af7207c
.
0..........
50000..........
100000..........
150000..........
200000..........
250000..........
300000..........
350000.
358612_len:_33000072
00000000000000|5qhprnmn1ly|USD|nrxkhbf|qbp37baynr1ty0f5f6mj8||BROAD|2|0|0||0|||0|0|0|0|0|
00000000000001|5kazpm60x|USD|zkmi0sdr8|khqed 6hsc7l7hs 1x7w853||BROAD|2|0|0||0|||0|0|0|0|0|
00000000000002|icmr r4hf48|USD|rylyvppfqde45xay glsr|5si5mwlm2ndq||BROAD|2|0|0||0|||0|0|0|0|0|
00000000000003|yyf i z13p8u|USD|ge0l22txoo011000sl |x zu4kuk86uup6 a||BROAD|2|0|0||0|||0|0|0|0|0|
00000000000004|qsyfs8la2|USD|i7ogbxl1dgpyqwl6vqpf6|g 7tqdvysq||BROAD|2|0|0||0|||0|0|0|0|0|
00000000000005|qh5s88pu|USD|m
__WD_Post  Success [0] : HTTP status = 200
_WD_ExecuteScript  Success [0]
__WD_Post  Webdriver Exception [10] : HTTP status = 500
_WD_ExecuteScript  Webdriver Exception [10] : unknown error: Runtime.callFunctionOn threw exception: SyntaxError: Unexpected token ')'
  (Session info: chrome=116.0.5845.188)
10___0

Expand  

Why this size limit?
How can I solve?
TIA

Edited by frank10
Posted
  On 9/27/2023 at 9:51 AM, frank10 said:

_WD_ExecuteScript  Webdriver Exception [10] : unknown error: Runtime.callFunctionOn threw exception: SyntaxError: Unexpected token ')'

Expand  

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 9/27/2023 at 9:51 AM, frank10 said:

_WD_Startup: Webdriver UDF:    1.1.1 (Update available)

Expand  

update your UDF version

https://github.com/Danp2/au3WebDriver/releases/tag/1.2.0

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 9/27/2023 at 9:58 AM, mLipok said:
Expand  

I updated, but the result is the same.
The unknown error with unexpected token ")" appears only when you use the big size: if you test with the "ok.txt" size, it does not give the error.
So the problem isn't in the script or in the generated string, but maybe in some truncating process of _WD_post or similar... it seems due to size exceeding some limit...

Posted

modified repro script

#include <MsgBoxConstants.au3>
#AutoIt3Wrapper_UseX64=Y

#include "..\wd_capabilities.au3"
#include "..\wd_helper.au3"

Global $sSession
ConsoleWrite("! $_WD_DEBUG = " & $_WD_DEBUG & @CRLF)
_Example()
Func _Example()
    _Init('chrome')
;~  _Init('firefox')
    If @error Then Return SetError(@error, @extended, 0)

    Local $sStr = ''
    Local $fileName = "ko.txt" ;********** use this line if you want to see the ERROR
;~  $fileName = "ok.txt"        ;********** use this line if you want to test a slighlty less string size that WORKS

    ;********** generate string size:
;~ 32000000 ok  31251KB
;~ 33000000 ko  32227KB
    For $i = 0 To 365000 ; string rows
;~  For $i = 0 To 100 ; string rows
        $sStr &= StringFormat("%014d", $i) & "|" & _MakeString(6, 12) & "|USD|" & _MakeString(6, 23) & "|" & _MakeString(8, 25) & "|" & "|BROAD|2|0|0||0|||0|0|0|0|0|" & @CRLF
        If Mod($i, 5000) = 0 Then ConsoleWrite(".")
        If Mod($i, 50000) = 0 Then ConsoleWrite(@CRLF & $i)
        If ($fileName = "ok.txt" And StringLen($sStr) >= 32000000) Or ($fileName = "ko.txt" And StringLen($sStr) >= 33000000) Then ExitLoop
    Next

    ConsoleWrite(@CRLF & $i & "_len:_" & StringLen($sStr) & @CRLF)
    ; **** if you want to save the file:
;~ local $hFile = FileOpen($fileName, 2 )
;~ FileWrite($hFile, $sStr)
;~ FileClose($hFile)
    ConsoleWrite(StringLeft($sStr, 500) & @CRLF) ; test example string


    $sStr = 'var sTemp = "";' & @CRLF & 'sTemp = `' & $sStr & '`;'
    _WD_ExecuteScript($sSession, $sStr)
    ConsoleWrite(@error & "___" & @extended & @CRLF)
    ClipPut($sStr)
    MsgBox(0, '', 'sent?')

EndFunc   ;==>_Example

Func _Init($sBrowser)
    $_WD_DEBUG = $_WD_DEBUG_Info
    Local $sCapabilities
    Switch $sBrowser
        Case 'chrome'
            _WD_UpdateDriver('chrome')
            _WD_Option('Driver', 'chromedriver.exe')
        $sCapabilities = SetupChrome(False)
        Case 'firefox'
            _WD_UpdateDriver('firefox')
            _WD_Option('Driver', 'geckodriver.exe')
        $sCapabilities = SetupGecko(False)
    EndSwitch
    _WD_Option('Port', _WD_GetFreePort())
    Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT
    _WD_Option('DriverParams', $sDriverParams)

    _WD_Startup()

    $sSession = _WD_CreateSession($sCapabilities)
    If @error Then Return SetError(@error, @extended, 0)

EndFunc   ;==>_Init


Func _MakeString($min, $max)
    Local $aSplit = StringSplit(' abcdefghijklmnopqrstuvwxyz0123456789', '')
    Local $sHoldString = ''
    For $iCC = 1 To Random($min, $max, 1)
        $sHoldString &= $aSplit[Random(1, 36, 1)]
    Next
    Return $sHoldString
EndFunc   ;==>_MakeString


Func SetupGecko($bHeadless)
    _WD_Option('Driver', 'geckodriver.exe')
    _WD_Option('DriverParams', '--log trace')
    _WD_Option('Port', 4444)

;~  Local $sCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}'
    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch', 'firefox')
    _WD_CapabilitiesAdd('browserName', 'firefox')
    _WD_CapabilitiesAdd('acceptInsecureCerts', True)
    ; REMARKS
    ; When using 32bit geckodriver.exe, you may need to set 'binary' option.
    ; This shouldn't be needed when using 64bit geckodriver.exe,
    ;  but at the same time setting it is not affecting the script.
    Local $sPath = _WD_GetBrowserPath("firefox")
    If Not @error Then
        _WD_CapabilitiesAdd('binary', $sPath)
        ConsoleWrite("wd_demo.au3: _WD_GetBrowserPath() > " & $sPath & @CRLF)
    EndIf

    If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless')
    _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo
    Local $sCapabilities = _WD_CapabilitiesGet()
    Return $sCapabilities
EndFunc   ;==>SetupGecko

Func SetupChrome($bHeadless)
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

;~  Local $sCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}'
    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch', 'chrome')
    _WD_CapabilitiesAdd('w3c', True)
    _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
    If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless')
    _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo
    Local $sCapabilities = _WD_CapabilitiesGet()
    Return $sCapabilities
EndFunc   ;==>SetupChrome

 

I think this can be related to winhttp.au3 udf but maybe to JSON.au3 or strictly to WebDriver exe.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 9/27/2023 at 11:00 AM, mLipok said:

modified repro script

#include <MsgBoxConstants.au3>
#AutoIt3Wrapper_UseX64=Y

#include "..\wd_capabilities.au3"
#include "..\wd_helper.au3"

Global $sSession
ConsoleWrite("! $_WD_DEBUG = " & $_WD_DEBUG & @CRLF)
_Example()
Func _Example()
    _Init('chrome')
;~  _Init('firefox')
    If @error Then Return SetError(@error, @extended, 0)

    Local $sStr = ''
    Local $fileName = "ko.txt" ;********** use this line if you want to see the ERROR
;~  $fileName = "ok.txt"        ;********** use this line if you want to test a slighlty less string size that WORKS

    ;********** generate string size:
;~ 32000000 ok  31251KB
;~ 33000000 ko  32227KB
    For $i = 0 To 365000 ; string rows
;~  For $i = 0 To 100 ; string rows
        $sStr &= StringFormat("%014d", $i) & "|" & _MakeString(6, 12) & "|USD|" & _MakeString(6, 23) & "|" & _MakeString(8, 25) & "|" & "|BROAD|2|0|0||0|||0|0|0|0|0|" & @CRLF
        If Mod($i, 5000) = 0 Then ConsoleWrite(".")
        If Mod($i, 50000) = 0 Then ConsoleWrite(@CRLF & $i)
        If ($fileName = "ok.txt" And StringLen($sStr) >= 32000000) Or ($fileName = "ko.txt" And StringLen($sStr) >= 33000000) Then ExitLoop
    Next

    ConsoleWrite(@CRLF & $i & "_len:_" & StringLen($sStr) & @CRLF)
    ; **** if you want to save the file:
;~ local $hFile = FileOpen($fileName, 2 )
;~ FileWrite($hFile, $sStr)
;~ FileClose($hFile)
    ConsoleWrite(StringLeft($sStr, 500) & @CRLF) ; test example string


    $sStr = 'var sTemp = "";' & @CRLF & 'sTemp = `' & $sStr & '`;'
    _WD_ExecuteScript($sSession, $sStr)
    ConsoleWrite(@error & "___" & @extended & @CRLF)
    ClipPut($sStr)
    MsgBox(0, '', 'sent?')

EndFunc   ;==>_Example

Func _Init($sBrowser)
    $_WD_DEBUG = $_WD_DEBUG_Info
    Local $sCapabilities
    Switch $sBrowser
        Case 'chrome'
            _WD_UpdateDriver('chrome')
            _WD_Option('Driver', 'chromedriver.exe')
        $sCapabilities = SetupChrome(False)
        Case 'firefox'
            _WD_UpdateDriver('firefox')
            _WD_Option('Driver', 'geckodriver.exe')
        $sCapabilities = SetupGecko(False)
    EndSwitch
    _WD_Option('Port', _WD_GetFreePort())
    Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT
    _WD_Option('DriverParams', $sDriverParams)

    _WD_Startup()

    $sSession = _WD_CreateSession($sCapabilities)
    If @error Then Return SetError(@error, @extended, 0)

EndFunc   ;==>_Init


Func _MakeString($min, $max)
    Local $aSplit = StringSplit(' abcdefghijklmnopqrstuvwxyz0123456789', '')
    Local $sHoldString = ''
    For $iCC = 1 To Random($min, $max, 1)
        $sHoldString &= $aSplit[Random(1, 36, 1)]
    Next
    Return $sHoldString
EndFunc   ;==>_MakeString


Func SetupGecko($bHeadless)
    _WD_Option('Driver', 'geckodriver.exe')
    _WD_Option('DriverParams', '--log trace')
    _WD_Option('Port', 4444)

;~  Local $sCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}'
    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch', 'firefox')
    _WD_CapabilitiesAdd('browserName', 'firefox')
    _WD_CapabilitiesAdd('acceptInsecureCerts', True)
    ; REMARKS
    ; When using 32bit geckodriver.exe, you may need to set 'binary' option.
    ; This shouldn't be needed when using 64bit geckodriver.exe,
    ;  but at the same time setting it is not affecting the script.
    Local $sPath = _WD_GetBrowserPath("firefox")
    If Not @error Then
        _WD_CapabilitiesAdd('binary', $sPath)
        ConsoleWrite("wd_demo.au3: _WD_GetBrowserPath() > " & $sPath & @CRLF)
    EndIf

    If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless')
    _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo
    Local $sCapabilities = _WD_CapabilitiesGet()
    Return $sCapabilities
EndFunc   ;==>SetupGecko

Func SetupChrome($bHeadless)
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

;~  Local $sCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}'
    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch', 'chrome')
    _WD_CapabilitiesAdd('w3c', True)
    _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
    If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless')
    _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo
    Local $sCapabilities = _WD_CapabilitiesGet()
    Return $sCapabilities
EndFunc   ;==>SetupChrome

 

I think this can be related to winhttp.au3 udf but maybe to JSON.au3 or strictly to WebDriver exe.

 

Expand  

 

Ok, but this part is working to test the error, but it's not working browser side (with "ok.txt"):
 

$sStr = 'var sTemp = "";' & @CRLF & 'sTemp = `' & $sStr & '`;'
    _WD_ExecuteScript($sSession, $sStr)

If you want to declare a var in the browser and then assign a value to it from WD, you must first declare it with one _WD_ExecuteScript and then assign it with another one, like I did.
Otherwise, if you open the chrome console and write this:

console.log(sTemp)

it says the var isn't declared and so it has no value...

So, it should remain:

_WD_ExecuteScript($sSession, 'var sTemp = "";' ) 
_WD_ExecuteScript($sSession, 'sTemp = `' & $sStr & '`;' )

And after, if you write console.log(sTemp) you get the correct string value.

Edited by frank10
Posted (edited)

take a look into _WD_ElementSelectAction()

"var SelectElement = arguments[0];" & _
"var LabelsToSplit = arguments[1];" & _ ; Label1||Label2
"var LabelsToSelect = LabelsToSplit.split('||');" & _ ; ['Label1', 'Label2']
"var AllowMultiple = arguments[2];" & _ ; true or false
"return MultiSelectOption(SelectElement, LabelsToSelect, AllowMultiple);" & _

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

I'm not sure what you mean. But, yes, of course in JS code is perfectly fine declaring and assigning a var all in one line.

The problem is making this with _WD_ExecuteScript

 

This works inside the browser, you can test in the console:

var sTest = ""; sTest = "testString"; console.log(sTest);

And the global var sTest is correctky created.

But if you do this in Autoit:

_WD_ExecuteScript( $sSession, 'var sTest = ""; sTest = "testString"; console.log(sTest); ')

it correctly outputs the value (as if the var has a local scope), BUT if you call the sTest var it says it's not defined!
I uploaded a pic with the first lines executed by Autoit and not finding the global var and the last ones by console, correctly creating global var.

 

Instead if you split the code into 2 calls, it works also creating a global var:

_WD_ExecuteScript( $sSession, 'var sTest = "";')
_WD_ExecuteScript( $sSession, 'sTest = "testString"; console.log(sTest);')

 

globalScopeVar.png

Edited by frank10
Posted

BTW1: I don't know why it spaces the post like this, I wrote it into Code... I tried to edit it but I can't justify correctly...??

BTW2: once it crashed my browser, but after reloading the page it seems it didn't save the text I wrote... sometimes it restores it sometimes not (it keeped the pic uploaded but not the text...)

  • Solution
Posted
  On 9/27/2023 at 4:36 PM, Nine said:

Try concatenating the string instead of assigning it at once. I tried with 2 chunks of 20mb and it worked fine...

Expand  

Yes, that's a good workaround. Waiting for the correct fix...

Posted
  On 9/27/2023 at 5:54 PM, Danp2 said:

Works fine with Geckodriver, so that would suggest that the issue resides in Chromedriver.

Expand  

Interesting, I thought it was something with winhhtp or _WD_Post, instead...

 

Posted (edited)

For the global var problem, the problem seems to be the word "var" or even "let" before the var you want to become global:
 
How to test:
insert these lines separately, look at the console and you see the correct output from console.log(),
BUT this is only a local var output, not a proof of the creation of an accessible global var.
Manually write the name of the var in the console and see if it appears the correct value -> global var created;
if it gives error var not defined -> not created.

;This does not work in creating a global var:
_WD_ExecuteScript($sSession, 'var sTemp = ""; sTemp = "222"; console.log(sTemp)' ) 

;This works because the first line with "var" is ignored, the line working is only the 2°:
_WD_ExecuteScript($sSession, 'var sTemp = "";' ) 
_WD_ExecuteScript($sSession, 'sTemp = "222"; console.log(sTemp)' ) 

;In fact this single line alone works :
_WD_ExecuteScript($sSession, 'sTemp = "222"; console.log(sTemp)' ) 

;and also this one works:
_WD_ExecuteScript($sSession, 'sTemp = ""; sTemp += "222"; console.log(sTemp)' ) 

;but this does not work because of "var":
_WD_ExecuteScript($sSession, 'var sTemp = ""; sTemp += "222"; console.log(sTemp)' ) 
;the same err using "let" instead of "var"...:
_WD_ExecuteScript($sSession, 'let sTemp = ""; sTemp += "222"; console.log(sTemp)' )

So, it seems the actual workaround is avoiding declaring a var with "var" or "let" or even "const".
But the code should be corrected to accept these keywords...

Edited by frank10
Posted
  On 9/28/2023 at 2:54 PM, Danp2 said:

@frank10 There isn't anything in the UDF that would cause this behavior AFAIK, so I suspect an issue or limitation with Chrome. You should test using one of the other supported browsers to confirm.

P.S. I'd be interested to learn more about your Use Case for the original issue of "I must send a huge string file with WD to JS var on chrome."

Expand  

I explain what I do:
I need to pass some data I collected in a txt file from several xlsx into a JS page on chrome to further evaluation and creation of tables, graphs etc. There are ads data over the years, by kw, campaigns etc And also selling data by markets, types and so on...
Browser side, with JS I will convert the string var to array to manipulate it better.
But since Autoit is very slow creating huge arrays and passing them to JS, I ended up it's a lot faster reading a txt file and directly passing it as a string to chrome that later will transform it to array.
It worked well up to now with this size problem. Now I ended up as Nine suggestion, reading the file into a string and splitting the string in a for cycle with StringMid() in 30000000 chuncks of bytes and passing them to chrome concatenating the string on JS.
It works well and fast as a single passing!

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...