mLipok Posted January 2, 2022 Share Posted January 2, 2022 I was working on this and print properties: Here is my code expandcollapse popup#AutoIt3Wrapper_UseX64=N #include "wd_helper.au3" #include "wd_capabilities.au3" _Example() Func _Example() Local $sSession = _MY__WD_SetupChrome(True) Local $sFilePath = @ScriptDir & "\PackingSlip.html" Local $s_HTML_File = "file:///" & StringReplace($sFilePath, "\", "/") ConsoleWrite("! $s_HTML_File = " & $s_HTML_File & @CRLF) _WD_Navigate($sSession, $s_HTML_File) ; https://www.w3.org/TR/webdriver/#print-page _Test($sSession, Default, 'PackingSlip_1_Default.pdf') ; https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-12272021/?do=findComment&comment=1478997 _Test($sSession, '{"pageRanges": ["1-2"]}', 'PackingSlip_1_PageRanges.pdf') ; https://www.autoitscript.com/forum/topic/206095-use-vba-code-with-firefox-in-webdriver/ _Test($sSession, '{"background": true}', 'PackingSlip_1_Background.pdf') ; https://stackoverflow.com/a/68353518/5314940 ; http://www.polger.wroclaw.pl/Formaty-papieru,51.html _Test($sSession, '{"pageWidth": 21.59, "pageHeight": 27.94}', 'PackingSlip_1_Letter.pdf') ; this are default values _Test($sSession, '{"pageWidth": 21.00, "pageHeight": 29.70}', 'PackingSlip_1_A4.pdf') _Test($sSession, '{"pageWidth": 29.70, "pageHeight": 42.00}', 'PackingSlip_1_A3.pdf') _WD_Shutdown() EndFunc ;==>_Example Func _Test($sSession, $sOptions, $sFileName) Local $dBinaryDataToWrite = _WD_PrintToPdf($sSession, $sOptions) Local $hFile = FileOpen(@ScriptDir & "\" & $sFileName, $FO_OVERWRITE + $FO_BINARY) FileWrite($hFile, $dBinaryDataToWrite) FileClose($hFile) EndFunc ;==>_Test Func _MY__WD_SetupChrome($b_Headless = False, $s_Download_dir = '', $_WD_DEBUG_LEVEL = Default, $s_Log_FileFullPath = Null) If $_WD_DEBUG_LEVEL = Default Then $_WD_DEBUG = $_WD_DEBUG_Error If Not @Compiled Then $_WD_DEBUG = $_WD_DEBUG_Info EndIf _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DefaultTimeout', 1000) _WD_UpdateDriver('chrome') If @error Then Return SetError(@error, @extended, '') # !!! WARRNING !!! AS DEFAULT DO NOT USE '--log-path=' BECAUSE OF GDPR / RODO law rules If $s_Log_FileFullPath = Default Then Local $s_Default_Log_File = @ScriptDir & '\Log\' & @YEAR & @MON & @MDAY & '-' & @HOUR & @MIN & @SEC & ' WebDriver - Chrome - Testing.log' _WD_Option('DriverParams', '--log-path=' & '"' & $s_Default_Log_File & '"') EndIf _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch') _WD_CapabilitiesAdd('acceptInsecureCerts', True) _WD_CapabilitiesAdd('firstMatch', 'chrome') _WD_CapabilitiesAdd('browserName', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('args', 'user-data-dir', 'C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data\Default') _WD_CapabilitiesAdd('args', 'user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win' & StringReplace(@OSArch, 'X', '') & '; ' & @CPUArch & ') AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' & _WD_GetBrowserVersion('chrome') & ' Safari/537.36') _WD_CapabilitiesAdd('args', '--profile-directory', Default) _WD_CapabilitiesAdd('args', 'start-maximized') _WD_CapabilitiesAdd('args', 'disable-infobars') _WD_CapabilitiesAdd('args', '--no-sandbox') _WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled') _WD_CapabilitiesAdd('args', '--disable-web-security') _WD_CapabilitiesAdd('args', '--allow-running-insecure-content') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('args', '--ignore-certificate-errors') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('prefs', 'credentials_enable_service', False) ; https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-12272021/?do=findComment&comment=1464829 If $b_Headless Then _ _WD_CapabilitiesAdd('args', '--headless') If $s_Download_dir Then _ _WD_CapabilitiesAdd('prefs', 'download.default_directory', $s_Download_dir) _WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking') ; https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') _WD_CapabilitiesAdd('excludeSwitches', 'load-extension') _WD_CapabilitiesDump(@ScriptLineNumber & ':WebDriver: testing') Local $s_Capabilities = _WD_CapabilitiesGet() _WD_Startup() If @error Then Return SetError(@error, @extended) Local $WD_SESSION = _WD_CreateSession($s_Capabilities) Return SetError(@error, @extended, $WD_SESSION) EndFunc ;==>_MY__WD_SetupChrome but I have issue with setting "pageWidth" and "pageHeight" _Test($sSession, '{"pageWidth": 21.59, "pageHeight": 27.94}', 'PackingSlip_1_Letter.pdf') ; this are default values _Test($sSession, '{"pageWidth": 21.00, "pageHeight": 29.70}', 'PackingSlip_1_A4.pdf') _Test($sSession, '{"pageWidth": 29.70, "pageHeight": 42.00}', 'PackingSlip_1_A3.pdf') The problem is with generated PDF each of them have 8,50 x 11,00 inches, but they should differ. So the main question is why such usage: _WD_PrintToPdf($sSession, '{"pageWidth": 29.70, "pageHeight": 42.00}') does not change the print parameters and thus the PDF file has incorrect page size. Any body know how to fix this ? PackingSlip.html TheDcoder 1 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 Link to comment Share on other sites More sharing options...
mLipok Posted January 2, 2022 Share Posted January 2, 2022 (edited) 5 hours ago, TheDcoder said: Here's the demo code I used to test this: _WD_ExecuteScript($sSession, 'setTimeout(() => arguments[0]("foobar"), 3000)', True) Thanks for yours demo code. I used them in my testing script: expandcollapse popup#AutoIt3Wrapper_UseX64=N #include "wd_helper.au3" #include "wd_capabilities.au3" _Example() Func _Example() Local $sSession = _MY__WD_SetupChrome(True) _WD_Navigate($sSession, 'https://www.google.com') Sleep(1000) Local $sJavaScript = 'setTimeout(() => arguments[0]("foobar"), 3000); return true;' Local $hTimer, $sResult $hTimer = TimerInit() $sResult = _WD_ExecuteScript($sSession, $sJavaScript, Default, True, "[value]") ConsoleWrite("! After $bAsync = True: Elapsed time = " & TimerDiff($hTimer) / 1000 & " $sResult = " & $sResult & @CRLF) $hTimer = TimerInit() $sResult = _WD_ExecuteScript($sSession, $sJavaScript, Default, False, "[value]") ConsoleWrite("! After $bAsync = False: Elapsed time = " & TimerDiff($hTimer) / 1000 & " $sResult = " & $sResult & @CRLF) _WD_Shutdown() EndFunc ;==>_Example Func _MY__WD_SetupChrome($b_Headless = False, $s_Download_dir = '', $_WD_DEBUG_LEVEL = Default, $s_Log_FileFullPath = Null) If $_WD_DEBUG_LEVEL = Default Then $_WD_DEBUG = $_WD_DEBUG_Error If Not @Compiled Then $_WD_DEBUG = $_WD_DEBUG_Info EndIf _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DefaultTimeout', 1000) _WD_UpdateDriver('chrome') If @error Then Return SetError(@error, @extended, '') # !!! WARRNING !!! AS DEFAULT DO NOT USE '--log-path=' BECAUSE OF GDPR / RODO law rules If $s_Log_FileFullPath = Default Then Local $s_Default_Log_File = @ScriptDir & '\Log\' & @YEAR & @MON & @MDAY & '-' & @HOUR & @MIN & @SEC & ' WebDriver - Chrome - Testing.log' _WD_Option('DriverParams', '--log-path=' & '"' & $s_Default_Log_File & '"') EndIf _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch') _WD_CapabilitiesAdd('acceptInsecureCerts', True) _WD_CapabilitiesAdd('firstMatch', 'chrome') _WD_CapabilitiesAdd('browserName', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('args', 'user-data-dir', 'C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data\Default') _WD_CapabilitiesAdd('args', 'user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win' & StringReplace(@OSArch, 'X', '') & '; ' & @CPUArch & ') AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' & _WD_GetBrowserVersion('chrome') & ' Safari/537.36') _WD_CapabilitiesAdd('args', '--profile-directory', Default) _WD_CapabilitiesAdd('args', 'start-maximized') _WD_CapabilitiesAdd('args', 'disable-infobars') _WD_CapabilitiesAdd('args', '--no-sandbox') _WD_CapabilitiesAdd('args', '--disable-blink-features=AutomationControlled') _WD_CapabilitiesAdd('args', '--disable-web-security') _WD_CapabilitiesAdd('args', '--allow-running-insecure-content') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('args', '--ignore-certificate-errors') ; https://stackoverflow.com/a/60409220 _WD_CapabilitiesAdd('prefs', 'credentials_enable_service', False) ; https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-12272021/?do=findComment&comment=1464829 If $b_Headless Then _ _WD_CapabilitiesAdd('args', '--headless') If $s_Download_dir Then _ _WD_CapabilitiesAdd('prefs', 'download.default_directory', $s_Download_dir) _WD_CapabilitiesAdd('excludeSwitches', 'disable-popup-blocking') ; https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') _WD_CapabilitiesAdd('excludeSwitches', 'load-extension') _WD_CapabilitiesDump(@ScriptLineNumber & ':WebDriver: testing') Local $s_Capabilities = _WD_CapabilitiesGet() _WD_Startup() If @error Then Return SetError(@error, @extended) Local $WD_SESSION = _WD_CreateSession($s_Capabilities) Return SetError(@error, @extended, $WD_SESSION) EndFunc ;==>_MY__WD_SetupChrome and here is my console output: Quote __WD_Post: URL=HTTP://127.0.0.1:9515/session/a55df213e132c73926e1dbb61c80ddc1/execute/async; $sData={"script":"setTimeout(() => arguments[0](\"foobar\"), 3000); return true;", "args":[]} __WD_Post: StatusCode=200; ResponseText={"value":"foobar"}... _WD_ExecuteScript: {"value":"foobar"}... _WD_ExecuteScript ==> Success: HTTP status = 200! After $bAsync = True: Elapsed time = 3.0941156 $sResult = foobar __WD_Post: URL=HTTP://127.0.0.1:9515/session/a55df213e132c73926e1dbb61c80ddc1/execute/sync; $sData={"script":"setTimeout(() => arguments[0](\"foobar\"), 3000); return true;", "args":[]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}... _WD_ExecuteScript ==> Success: HTTP status = 200! After $bAsync = False: Elapsed time = 0.0179604 $sResult = True My question is : Why in Async mode code execution tooks 3 seconds , and in Sync mode code execution tooks 0.017 seconds ? I expected the opposite, I mean I expected that the execution time would be shorter in Async mode, and longer in Sync mode. Edited January 2, 2022 by mLipok TheDcoder 1 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 Link to comment Share on other sites More sharing options...
mLipok Posted January 2, 2022 Share Posted January 2, 2022 3 hours ago, Danp2 said: @mLipok I would interpret that to mean that frames located within another frame would not be included in the count. So this would be better description: Quote ; Remarks .......: The function will not traverse to nested frames - will count frames only from current context/document 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 Link to comment Share on other sites More sharing options...
TheDcoder Posted January 2, 2022 Share Posted January 2, 2022 4 hours ago, mLipok said: Why in Async mode code execution tooks 3 seconds , and in Sync mode code execution tooks 0.017 seconds ? That's because I used the setTimeout function to run the anonymous function with a delay of 3 seconds JavaScript doesn't have sleep function due to how it's designed, so we have to use work-around like callbacks and timers, and with modern ES6 version of JS we now have Promises and new keywords to simulate a procedural execution in async code. It can be a little hard to grasp if you aren't used to thinking that way. TL;DR JavaScript doesn't have sleep so async mode is required if you need to wait for anything in your code. 4 hours ago, mLipok said: I expected the opposite, I mean I expected that the execution time would be shorter in Async mode, and longer in Sync mode. As I explained above, the terms can be misleading. The advantage of using async mode is that you have more flexibility as you can call the "return function" whenever you want, that means being able to wait for something (e.g. an event) to occur, this wouldn't be possible in sync scripts because there is no sleep function. mLipok 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
mLipok Posted January 2, 2022 Share Posted January 2, 2022 (edited) I must re read this couple of times, because I feel like I still live in 2021. Edited January 2, 2022 by mLipok TheDcoder and seadoggie01 2 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 Link to comment Share on other sites More sharing options...
Danp2 Posted January 2, 2022 Author Share Posted January 2, 2022 7 hours ago, mLipok said: So this would be better description: Quote ; Remarks .......: The function will not traverse to nested frames - will count frames only from current context/document I would suggest that the entire header be reviewed / revised to better describe the functionality. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mLipok Posted January 3, 2022 Share Posted January 3, 2022 On 1/2/2022 at 5:24 AM, mLipok said: So the main question is why such usage: _WD_PrintToPdf($sSession, '{"pageWidth": 29.70, "pageHeight": 42.00}') does not change the print parameters and thus the PDF file has incorrect page size. Any body know how to fix this ? As so far I used CSShttps://stackoverflow.com/a/63190969/5314940 @page { size: A3; } but it would be nice to know how to do this via WebDriver UDF as a print options. 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 Link to comment Share on other sites More sharing options...
TheDcoder Posted January 3, 2022 Share Posted January 3, 2022 @mLipok You can try the Page.printToPDF CDP command, it allows you to specify many options, including paperWidth and paperHeight which seems to be exactly what you are looking for Maybe we can even modify the existing function in the helper UDF to use this for ChromeDriver mLipok 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
mLipok Posted January 3, 2022 Share Posted January 3, 2022 (edited) Of course, but that doesn't change the fact that it should work the way I'm asking. So I decide to also ask question here:https://stackoverflow.com/questions/70570109/webdriver-print-with-desired-pagewidth-pageheight Edited January 3, 2022 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 Link to comment Share on other sites More sharing options...
mLipok Posted January 3, 2022 Share Posted January 3, 2022 (edited) I have done some speed up in: _WD_ElementSelectAction() It is based on RegExp: #include <Array.au3> _Example() Func _Example() Local $sHTML = _ '<select id="OptionToChoose">' & @CRLF & _ ' <option value="" selected="selected">Choose option</option>' & @CRLF & _ ' <option value="1">Sun</option>' & @CRLF & _ ' <option value="2">Earth</option>' & @CRLF & _ ' <option value="3">Moon</option>' & @CRLF & _ '</select>' & @CRLF & _ '' Local $aOuter = StringRegExp($sHTML, '(?is)(<option value="(.*?)"( selected="selected"|.*?)>(.*?)</option>)', $STR_REGEXPARRAYGLOBALFULLMATCH) _ArrayDisplay($aOuter, '$aOuter') Local $aInner For $IDX_Out = 0 To UBound($aOuter) - 1 $aInner = $aOuter[$IDX_Out] _ArrayDisplay($aInner, '$aInner = $aOuter[$IDX_Out] ... $IDX_Out = ' & $IDX_Out) Next EndFunc ;==>_Example instead of using: $sText = "" For $sElement In $aOptions $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}' $sText &= (($sText <> "") ? @CRLF : "") & _WD_ExecuteScript($sSession, "return arguments[0].value + '|' + arguments[0].label", $sJsonElement, Default, "[value]") $iErr = @error Next I have <select> with 351 options and In my test it is a great speed up about 100x faster ! As so far need some more testing. btw. The example with RegExp was submited to SVN and will be available in future AutoIt HelpFile release. Edited January 3, 2022 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 Link to comment Share on other sites More sharing options...
mLipok Posted January 3, 2022 Share Posted January 3, 2022 (edited) On 12/31/2021 at 10:03 PM, Danp2 said: IDK without more details. Is this occurring with _WD_CreateSession? What data is being returned from Chromedriver to __WD_Post? I had the same issue today and here are my logs: Quote Starting ChromeDriver 96.0.4664.45 (76e4c1bb2ab4671b8beba3444e61c0f17584b2fc-refs/branch-heads/4664@{#947}) on port 9515 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. DevTools listening on ws://127.0.0.1:65418/devtools/browser/65ebc307-dd7a-426a-adba-33f276b991ea [0103/163746.485:ERROR:cache_util_win.cc(20)] Unable to move the cache: Odmowa dostŕpu. (0x5) [0103/163746.486:ERROR:cache_util.cc(144)] Unable to move cache folder C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\GPUCache to C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\old_GPUCache_000 [0103/163746.486:ERROR:disk_cache.cc(185)] Unable to create cache [0103/163746.486:ERROR:shader_disk_cache.cc(612)] Shader Cache Creation failed: -2 [0103/163746.784:ERROR:command_buffer_proxy_impl.cc(125)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer. [0103/163748.512:ERROR:cache_util_win.cc(20)] Unable to move the cache: Odmowa dostŕpu. (0x5) [0103/163748.513:ERROR:cache_util.cc(144)] Unable to move cache folder C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\Cache to C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\old_Cache_000 [0103/163748.514:ERROR:disk_cache.cc(185)] Unable to create cache [0103/163749.501:ERROR:service_worker_storage.cc(1899)] Failed to delete the database: Database IO error [0103/163752.545:ERROR:cache_util_win.cc(20)] Unable to move the cache: Odmowa dostŕpu. (0x5) [0103/163752.545:ERROR:cache_util.cc(144)] Unable to move cache folder C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\GPUCache to C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\old_GPUCache_000 [0103/163752.546:ERROR:disk_cache.cc(185)] Unable to create cache [0103/163752.546:ERROR:shader_disk_cache.cc(612)] Shader Cache Creation failed: -2 [0103/163752.804:INFO:CONSOLE(427)] "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu", source: https://przegladarka*****.pl/TSPD/08c5699bd4ab2000b1bfa704560d2c9b53582c7ceb44ecaa92a4eb737e6cb3fb321cbaf05f0bd06a?type=11 (427) [0103/163752.805:INFO:CONSOLE(427)] "The ScriptProcessorNode is deprecated. Use AudioWorkletNode instead. (https://bit.ly/audio-worklet)", source: https://przegladarka*****.pl/TSPD/08c5699bd4ab2000b1bfa704560d2c9b53582c7ceb44ecaa92a4eb737e6cb3fb321cbaf05f0bd06a?type=11 (427) [0103/163752.807:INFO:CONSOLE(430)] "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu", source: https://przegladarka*****.pl/TSPD/08c5699bd4ab2000b1bfa704560d2c9b53582c7ceb44ecaa92a4eb737e6cb3fb321cbaf05f0bd06a?type=11 (430) [0103/163752.807:INFO:CONSOLE(433)] "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu", source: https://przegladarka*****.pl/TSPD/08c5699bd4ab2000b1bfa704560d2c9b53582c7ceb44ecaa92a4eb737e6cb3fb321cbaf05f0bd06a?type=11 (433) [0103/163752.808:ERROR:web_contents_delegate.cc(228)] WebContentsDelegate::CheckMediaAccessPermission: Not supported. [0103/163752.808:ERROR:web_contents_delegate.cc(228)] WebContentsDelegate::CheckMediaAccessPermission: Not supported. [0103/163752.837:ERROR:gl_utils.cc(318)] [.WebGL-000031DC0007FF00]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels [0103/163752.982:ERROR:gl_utils.cc(318)] [.WebGL-000031DC0007FF00]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels [0103/163753.079:ERROR:gl_utils.cc(318)] [.WebGL-000031DC0007FF00]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels [0103/163753.173:INFO:CONSOLE(0)] "[.WebGL-000031DC0007FF00]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels", source: https://przegladarka*****.pl/TSPD/?type=20 (0) [0103/163753.174:INFO:CONSOLE(0)] "[.WebGL-000031DC0007FF00]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels", source: https://przegladarka*****.pl/TSPD/?type=20 (0) [0103/163753.175:INFO:CONSOLE(0)] "[.WebGL-000031DC0007FF00]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels", source: https://przegladarka*****.pl/TSPD/?type=20 (0) [0103/163753.607:ERROR:database.cc(1773)] Quota SQLite error: code 5 errno 33: database is locked sql: PRAGMA auto_vacuum [0103/163753.639:ERROR:database.cc(1773)] Quota SQLite error: code 5 errno 33: database is locked sql: PRAGMA journal_mode=TRUNCATE [0103/163755.193:ERROR:sandbox_origin_database.cc(190)] SandboxOriginDatabase failed at: Init@storage/browser/file_system/sandbox_origin_database.cc:94 with error: IO error: C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\File System\Origins/LOCK: File currently in use. (ChromeMethodBFE: 15::LockFile::2) [0103/163755.194:WARNING:sandbox_origin_database.cc(106)] Attempting to repair SandboxOriginDatabase. [0103/163755.439:ERROR:database.cc(1773)] Quota SQLite error: code 5 errno 33: database is locked sql: PRAGMA cache_size=500 [0103/163755.470:ERROR:database.cc(1773)] Quota SQLite error: code 5 errno 33: database is locked sql: SELECT 1 FROM sqlite_schema WHERE type=? AND name=? [0103/163755.500:ERROR:database.cc(1773)] Quota SQLite error: code 5 errno 33: database is locked sql: SELECT 1 FROM sqlite_schema WHERE type=? AND name=? [0103/163755.531:ERROR:database.cc(1773)] Quota SQLite error: code 5 errno 33: database is locked sql: SELECT 1 FROM sqlite_schema WHERE type=? AND name=? [0103/163755.562:ERROR:database.cc(1773)] Quota SQLite error: code 5 errno 33: database is locked sql: CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR) [0103/163755.562:ERROR:quota_database.cc(747)] Could not open the quota database, resetting. [0103/163758.480:ERROR:quota_database.cc(749)] Failed to reset the quota database. [0103/163759.241:WARNING:sandbox_origin_database.cc(140)] Failed to repair SandboxOriginDatabase. [0103/163801.248:ERROR:sandbox_origin_database.cc(190)] SandboxOriginDatabase failed at: Init@storage/browser/file_system/sandbox_origin_database.cc:94 with error: IO error: C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\File System\Origins/LOCK: File currently in use. (ChromeMethodBFE: 15::LockFile::2) [0103/163801.248:WARNING:sandbox_origin_database.cc(106)] Attempting to repair SandboxOriginDatabase. [0103/163805.309:WARNING:sandbox_origin_database.cc(140)] Failed to repair SandboxOriginDatabase. [0103/163807.328:ERROR:sandbox_origin_database.cc(190)] SandboxOriginDatabase failed at: Init@storage/browser/file_system/sandbox_origin_database.cc:94 with error: IO error: C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\File System\Origins/LOCK: File currently in use. (ChromeMethodBFE: 15::LockFile::2) [0103/163807.329:WARNING:sandbox_origin_database.cc(106)] Attempting to repair SandboxOriginDatabase. [0103/163811.379:WARNING:sandbox_origin_database.cc(140)] Failed to repair SandboxOriginDatabase. [0103/163813.393:ERROR:sandbox_origin_database.cc(190)] SandboxOriginDatabase failed at: Init@storage/browser/file_system/sandbox_origin_database.cc:94 with error: IO error: C:\Users\Szef\AppData\Local\Google\Chrome\User Data\Default\Default\File System\Origins/LOCK: File currently in use. (ChromeMethodBFE: 15::LockFile::2) [0103/163813.393:WARNING:sandbox_origin_database.cc(106)] Attempting to repair SandboxOriginDatabase. [0103/163817.439:WARNING:sandbox_origin_database.cc(140)] Failed to repair SandboxOriginDatabase. Also, I noticed that there were a lot of open GoogleChrome instances left in the background. btw. "Odmowa dostŕpu" should "Odmowa dostępu" and this mean "Access denied" Edited January 3, 2022 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 Link to comment Share on other sites More sharing options...
Danp2 Posted January 3, 2022 Author Share Posted January 3, 2022 (edited) 4 hours ago, mLipok said: I had the same issue today and here are my logs: Thanks, but I really wanted to see the contents of the Scite output panel so that I can see what details are being returned by Chromedriver to the calling program. Quote Also, I noticed that there were a lot of open GoogleChrome instances left in the background. Were those opened prior to running your script? That might explain the issue if you are using an existing profile. Edited January 3, 2022 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
TheDcoder Posted January 4, 2022 Share Posted January 4, 2022 (edited) 6 hours ago, mLipok said: I have done some speed up in: _WD_ElementSelectAction() It is based on RegExp: Nice trick, but we also need to keep the current version as it is more robust, the RegEx might fail in edge cases, there's a saying about using RegEx with HTML I would implement this with a flag to choose the method, and in my opinion the default should be the original method because it's accurate and has less chance of failing. If someone wants speed they can set $bFast = True to use the RegEx method Edited January 4, 2022 by TheDcoder seadoggie01 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
mLipok Posted January 4, 2022 Share Posted January 4, 2022 (edited) 1 hour ago, Danp2 said: Were those opened prior to running your script? That might explain the issue if you are using an existing profile. I use: _WD_CapabilitiesAdd('args', 'user-data-dir', 'C:\Users\' & @UserName & '\AppData\Local\Google\Chrome\User Data\Default') _WD_CapabilitiesAdd('args', '--profile-directory', Default) But it usually works fine. It usually had issues when I manually stopped the script and then killed the ChromeDriver.exe process. Edited January 4, 2022 by mLipok TheDcoder 1 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 Link to comment Share on other sites More sharing options...
TheDcoder Posted January 4, 2022 Share Posted January 4, 2022 9 minutes ago, mLipok said: But it usually works fine. It's a bad idea to use your global default profile with WD There are several reasons but the main one being that there would be conflicts, Chrome is not designed to use the same profile and share it with other independent instances. The best alternative I can think of is to simply make a copy of the profile you want and use that instead. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
seadoggie01 Posted January 4, 2022 Share Posted January 4, 2022 (edited) 20 hours ago, mLipok said: </option> Did you forget to escape the backslash in your RegEx? regex101 says it's an error Edit: And it's broken if selected comes before the value Edit2: Per the HTML Standard (?) a closing </option> tag isn't even required 13 hours ago, TheDcoder said: best I'd disagree without defining best. Your solution is the fast and easy, while not relying on a profile is probably better practice Edited January 4, 2022 by seadoggie01 TheDcoder and mLipok 1 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
mLipok Posted January 4, 2022 Share Posted January 4, 2022 1 hour ago, seadoggie01 said: Your solution is the fast and easy, while not relying on a profile is probably better practice What you mean saying "while not relying on a profile is probably better practice" ? 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 Link to comment Share on other sites More sharing options...
seadoggie01 Posted January 4, 2022 Share Posted January 4, 2022 Mostly I mean that all of the "stuff" that comes with a profile can't be relied upon to always be there. Because I use AutoIt primarily at work, I've needed to learn how to write my scripts so others can use them. So if I use the current users' profile, I can't assume anything will be there, because there's a chance they don't have the same (as a terrible example) bookmarks as me Of course, this is less important if you're developing only for yourself, but you still might run into issues if you switch computers, upgrade to Win11, etc. All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
mLipok Posted January 4, 2022 Share Posted January 4, 2022 (edited) 4 hours ago, seadoggie01 said: Did you forget to escape the backslash in your RegEx? regex101 says it's an error I was not aware so far because it works ...... so far. Tested, fixed, thanks. 4 hours ago, seadoggie01 said: Edit: And it's broken if selected comes before the value Working on. 4 hours ago, seadoggie01 said: Edit2: Per the HTML Standard (?) a closing </option> tag isn't even required Wouldn't it be weird if <select> didn't display any text in options? Even so Google Chrome Browser evalutes this following form: <option value="1" class="1" /> to this: <option value="1" class="1"></option> It looks like possible weired form is such form: <option></option> and this generates empty option element as so far I have:https://regex101.com/r/ba2YLV/1 expandcollapse popup#include <Array.au3> _Example() Func _Example() ;~ Local $sHTML = _ ;~ '<select id="OptionToChoose">' & @CRLF & _ ;~ ' <option value="" selected="selected">Choose option</option>' & @CRLF & _ ;~ ' <option value="1">Sun</option>' & @CRLF & _ ;~ ' <option value="2">Earth</option>' & @CRLF & _ ;~ ' <option value="3">Moon</option>' & @CRLF & _ ;~ '</select>' & @CRLF & _ ;~ '' Local $sHTML = _ '<select id="OptionToChoose">' & @CRLF & _ ' <option value="" selected="selected">Choose option</option>' & @CRLF & _ ' <option></option>' & @CRLF & _ ' <option value="1" class="1">Sun</option>' & @CRLF & _ ' <option class="2" value="2">Earth</option>' & @CRLF & _ ' <option class="3" selected="selected" value="3" color="blue">Moon</option>' & @CRLF & _ '</select>' & @CRLF & _ '' ConsoleWrite($sHTML & @CRLF) ; StringRegExp : $STR_REGEXPARRAYGLOBALFULLMATCH - Option 4, global return, php/preg_match_all() style Local $aOuter = StringRegExp($sHTML, '(?is)(?:<option)([^>]*)( value="[^"]*")([^>]*\>|\>)([^>]*)(?:<)', $STR_REGEXPARRAYGLOBALFULLMATCH) _ArrayDisplay($aOuter, '$aOuter') Local $aInner For $IDX_Out = 0 To UBound($aOuter) - 1 $aInner = $aOuter[$IDX_Out] ;~ StringInStr($aInner[] _ArrayDisplay($aInner, '$aInner = $aOuter[$IDX_Out] ... $IDX_Out = ' & $IDX_Out) Next EndFunc ;==>_Example Is this looks like a complex RegExp ? The main concet is to get value and option always on the same row. But I also need to know if there is any option seclected to return to ID of selected option. Edited January 4, 2022 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 Link to comment Share on other sites More sharing options...
mLipok Posted January 4, 2022 Share Posted January 4, 2022 (edited) I hope that this will be finall example: expandcollapse popup#include <Array.au3> _Example() Func _Example() ;~ Local $sHTML = _ ;~ '<select id="OptionToChoose">' & @CRLF & _ ;~ ' <option value="">Choose option</option>' & @CRLF & _ ;~ ' <option></option>' & @CRLF & _ ;~ ' <option value="1" class="1">Sun</option>' & @CRLF & _ ;~ ' <option class="2" selected="selected" value="2">Earth</option>' & @CRLF & _ ;~ ' <option class="3" value="3" color="blue">Moon</option>' & @CRLF & _ ;~ '</select>' & @CRLF & _ ;~ '' Local $sHTML = _ '<select id="OptionToChoose">' & @CRLF & _ ' <option value="" selected="selected">Choose option</option>' & @CRLF & _ ' <option></option>' & @CRLF & _ ' <option value="1" class="1">Sun</option>' & @CRLF & _ ' <option class="2" value="2">Earth</option>' & @CRLF & _ ' <option class="3" selected="selected" value="3" color="blue">Moon</option>' & @CRLF & _ '</select>' & @CRLF & _ '' ConsoleWrite($sHTML & @CRLF) ; StringRegExp : $STR_REGEXPARRAYGLOBALFULLMATCH - Option 4, global return, php/preg_match_all() style $sHTML = StringReplace($sHTML, '<option></option>', '<option value=""></option>') ; fix for '<option></option>' must contain value="" to RegExp works Local $aOuter = StringRegExp($sHTML, '(?is)(?:<option)([^>]*)( value="[^"]*")([^>]*\>|\>)([^>]*)(?:<)', $STR_REGEXPARRAYGLOBALFULLMATCH) ;~ _ArrayDisplay($aOuter, '$aOuter') Local $iSelectedOption = -1 Local $aInner, $sText = '' For $IDX_Out = 0 To UBound($aOuter) - 1 $aInner = $aOuter[$IDX_Out] If $iSelectedOption = -1 And (StringInStr($aInner[1], 'selected="selected"') Or StringInStr($aInner[3], 'selected="selected"')) Then $iSelectedOption = $IDX_Out _ArrayDisplay($aInner, '$aInner = $aOuter[$IDX_Out] ... $IDX_Out = ' & $IDX_Out) $aInner[2] = StringRegExpReplace($aInner[2], '(?i)(.+value=")(.*?)(")','$2') ; remove atribute name and quotation - only value is needed $sText &= (($sText <> "") ? @CRLF : "") & $aInner[2] & '|' & $aInner[4] Next ConsoleWrite("! $sText = " & @CRLF & $sText & @CRLF) ConsoleWrite("! $iSelectedOption = " & $iSelectedOption & @CRLF) Local $aOut[0][2] _ArrayAdd($aOut, $sText, 0, Default, @CRLF, 1) _ArrayDisplay($aOut, '$aOut $iSelectedOption = ' & $iSelectedOption) EndFunc ;==>_Example Edited January 4, 2022 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 Link to comment Share on other sites More sharing options...
Recommended Posts