frank10 Posted September 27, 2023 Posted September 27, 2023 (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: expandcollapse popup#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 Why this size limit? How can I solve? TIA Edited September 27, 2023 by frank10
mLipok Posted September 27, 2023 Posted September 27, 2023 5 minutes ago, frank10 said: _WD_ExecuteScript Webdriver Exception [10] : unknown error: Runtime.callFunctionOn threw exception: SyntaxError: Unexpected token ')' 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 Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
mLipok Posted September 27, 2023 Posted September 27, 2023 5 minutes ago, frank10 said: _WD_Startup: Webdriver UDF: 1.1.1 (Update available) 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 Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
frank10 Posted September 27, 2023 Author Posted September 27, 2023 14 minutes ago, mLipok said: update your UDF version https://github.com/Danp2/au3WebDriver/releases/tag/1.2.0 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...
mLipok Posted September 27, 2023 Posted September 27, 2023 modified repro script expandcollapse popup#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 Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
frank10 Posted September 27, 2023 Author Posted September 27, 2023 (edited) 34 minutes ago, mLipok said: modified repro script expandcollapse popup#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. 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 September 27, 2023 by frank10
mLipok Posted September 27, 2023 Posted September 27, 2023 (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 September 27, 2023 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 Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
frank10 Posted September 27, 2023 Author Posted September 27, 2023 (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);') Edited September 27, 2023 by frank10
frank10 Posted September 27, 2023 Author Posted September 27, 2023 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 Nine Posted September 27, 2023 Solution Posted September 27, 2023 Try concatenating the string instead of assigning it at once. I tried with 2 chunks of 20mb and it worked fine... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Danp2 Posted September 27, 2023 Posted September 27, 2023 Works fine with Geckodriver, so that would suggest that the issue resides in Chromedriver. Latest Webdriver UDF Release Webdriver Wiki FAQs
frank10 Posted September 28, 2023 Author Posted September 28, 2023 16 hours ago, Nine said: Try concatenating the string instead of assigning it at once. I tried with 2 chunks of 20mb and it worked fine... Yes, that's a good workaround. Waiting for the correct fix...
frank10 Posted September 28, 2023 Author Posted September 28, 2023 15 hours ago, Danp2 said: Works fine with Geckodriver, so that would suggest that the issue resides in Chromedriver. Interesting, I thought it was something with winhhtp or _WD_Post, instead...
frank10 Posted September 28, 2023 Author Posted September 28, 2023 (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 September 28, 2023 by frank10
Danp2 Posted September 28, 2023 Posted September 28, 2023 @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." Latest Webdriver UDF Release Webdriver Wiki FAQs
frank10 Posted September 28, 2023 Author Posted September 28, 2023 28 minutes ago, 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." 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!
Danp2 Posted September 28, 2023 Posted September 28, 2023 OIC. I think the more traditional way to handle this would be to upload the file and then read / process the data using JS. Latest Webdriver UDF Release Webdriver Wiki FAQs
frank10 Posted September 28, 2023 Author Posted September 28, 2023 Yes, but in my case I must stay locally.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now