Danp2 Posted May 26, 2021 Author Posted May 26, 2021 1 hour ago, seadoggie01 said: Here's the simplest reproducer I have That mimics the error, but not exactly a reproducer of the issue you described. Are you doing anything like utilizing an existing profile or loading any extensions? Quote Edge is discarding my tab when it is minimized Have you checked to see if there's a way to disable this feature under Webdriver? Latest Webdriver UDF Release Webdriver Wiki FAQs
seadoggie01 Posted May 26, 2021 Posted May 26, 2021 The original method is to load the webpage, wait an unknown amount of time while it's minimized (likely 5 minutes?) for it to be discarded, then attempt to navigate to the webpage again. Both methods return an error 10, extended 404, so I figured the faster method would be appreciated I have no extensions and I'm using the default profile. I've tried to find a method to avoid discarding, but it doesn't seem to be available. Chromium has a command-line option under Chrome OS, but it doesn't work for Edge on Windows. There's an option for aggressive discarding, but nothing I've seen to turn it off 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
Danp2 Posted May 26, 2021 Author Posted May 26, 2021 @seadoggie01 This appears to turn off that feature -- Local $sSession = _WD_CreateSession('{"capabilities":{"alwaysMatch": {"ms:edgeOptions": {"w3c": true, "prefs": {"plugins.always_open_pdf_externally": true, "edge.sleeping_tabs.enabled": false}}}}}') Latest Webdriver UDF Release Webdriver Wiki FAQs
seadoggie01 Posted May 27, 2021 Posted May 27, 2021 While I don't receive an error about those capabilities, it doesn't stop the tab from being discarded Danp2 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
dPilar Posted May 28, 2021 Posted May 28, 2021 (edited) Hello, Me and @mLipok we have problem with creating a sessions. There is no problem on our local computers. We only have a problem on some computers at customer's premises but not at all. Below is the function: Func _MY__WD_SetupChrome($b_Headless) $_WD_DEBUG = $_WD_DEBUG_Error _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) Local $s_Desired_Capabilities If $b_Headless Then $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default"]}}}}' ;~ $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default", "--no-sandbox"]}}}}' ;~ $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars"]}}}}' Else $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default"]}}}}' ;~ $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default", "--no-sandbox"]}}}}' ;~ $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"]}}}}' EndIf _WD_Startup() Local $WD_SESSION = _WD_CreateSession($s_Desired_Capabilities) Return SetError(@error, @extended, $WD_SESSION) EndFunc ;==>_MY__WD_SetupChrome We tried with diffrent Capabilities : 1. With this Capabilites $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default"]}}}}' we have such an error: ! @error=10 @extended=500 2. With this Capabilites: $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars"]}}}}' ;~ $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default", "--no-sandbox"]}}}}' we have such an error: ! @error=10 @extended=0 Maybe someone has encountered the above errors and knows how to solve the problem?? Edited May 28, 2021 by dPilar mLipok 1
Danp2 Posted May 28, 2021 Author Posted May 28, 2021 2 hours ago, dPilar said: $_WD_DEBUG = $_WD_DEBUG_Error Suggest that you comment out this line and then rerun your tests, If you aren't using Scite, you can set logging to a file with _WD_Option / Console. Then post the log here if you need additional help with diagnosing the error. P.S. The error 10 is $_WD_ERROR_Exception dPilar 1 Latest Webdriver UDF Release Webdriver Wiki FAQs
dPilar Posted May 31, 2021 Posted May 31, 2021 @Danp2 Thank you for the answer and advice. I found a solution. The computers had an updated version of Google Chrome to the latest version. Which made my chromedriver.exe unable to start. I download the lastes version chromedriver.exe and it started working. I have to write a function that checks Google Chrome version and update it automatically.
Danp2 Posted May 31, 2021 Author Posted May 31, 2021 @dPilar Have a look at _WD_UpdateDriver in wd_helper.au3. mLipok 1 Latest Webdriver UDF Release Webdriver Wiki FAQs
HJL Posted May 31, 2021 Posted May 31, 2021 (edited) Hi Dan, with the new version (91.) of chrome and chromedriver I sometimes get an error "no such window ... / already closed" when opening several new windows with $sNewHandle= _WD_Window($sSess, 'new', '{"type":"window"}') 2021-05-26 15:04:35 : _WD_Window new: err:10 {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=91.0.4472.77)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0085C013+2474003]\n\tOrdinal0 [0x007F29C1+2042305]\n\tOrdinal0 [0x00702F68+1060712]\n\tOrdinal0 [0x006EC406+967686]\n\tOrdinal0 [0x00748459+1344601]\n\tOrdinal0 [0x00754C82+1395842]\n\tOrdinal0 [0x007466DB+1337051]\n\tOrdinal0 [0x00723427+1192999]\n\tOrdinal0 [0x007242EE+1196782]\n\tOrdinal0 [0x00724279+1196665]\n\tGetHandleVerifier [0x009E96FC+1590332]\n\tGetHandleVerifier [0x00A98614+2306900]\n\tGetHandleVerifier [0x008E9E93+543699]\n\tGetHandleVerifier [0x008E92CE+540686]\n\tOrdinal0 [0x007F86BA+2066106]\n\tOrdinal0 [0x007FD1C8+2085320]\n\tOrdinal0 [0x007FD308+2085640]\n\tOrdinal0 [0x008067F3+2123763]\n\tBaseThreadInitThunk [0x75E3FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77AA7A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77AA7A4E+238]\n"}} The error comes just after New_Window withou any URL. Do you have an idea what could be the reason? Edited May 31, 2021 by HJL
Danp2 Posted May 31, 2021 Author Posted May 31, 2021 @HJL I've read where others have encountered issues with Chrome v91. Are you able to consistently reproduce the issue? If so, then please post a short reproducer. Latest Webdriver UDF Release Webdriver Wiki FAQs
mLipok Posted May 31, 2021 Posted May 31, 2021 (edited) Is there a way to change HTML element to my own ? I mean I want to change one <DIV> with my own content. Most of them I hide but I need to change one of them to add my own header to document, just before I print them to PDF. Edited May 31, 2021 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
Danp2 Posted May 31, 2021 Author Posted May 31, 2021 @mLipokI don't see any reason why you couldn't do this. FWIW, I generally ask myself "How would I do this from the developer console?" I then translate to using the webdriver functions once I work that out. Latest Webdriver UDF Release Webdriver Wiki FAQs
mLipok Posted May 31, 2021 Posted May 31, 2021 hmm... Do you mean that I could use _WD_ExecuteScript() ? 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
Danp2 Posted May 31, 2021 Author Posted May 31, 2021 @mLipokYes Latest Webdriver UDF Release Webdriver Wiki FAQs
mLipok Posted May 31, 2021 Posted May 31, 2021 _WD_ExecuteScript() + Quote window.document.getElementsByClassName("grey-box yellow-box")[0].outerHTML="<div>MY OWN CONTENT</div>" do the tricks. 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
HJL Posted May 31, 2021 Posted May 31, 2021 (edited) 21 hours ago, Danp2 said: @HJL I've read where others have encountered issues with Chrome v91. Are you able to consistently reproduce the issue? If so, then please post a short reproducer. Got it: #include "wd_core.au3" #include "wd_helper.au3" $_WD_DEBUG = $_WD_DEBUG_Info Local $sDesiredCapabilities, $sSession Local $sWebDriverFileChrome = @ScriptDir & "\chromedriver.exe" TestNewWindow() _WD_DeleteSession($sSession) _WD_Shutdown() Func TestNewWindow() SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) Local $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}') ConsoleWrite('>>WD_Window new: error:' & @error & " new window ok" & @CRLF) _WD_Window($sSession, 'Switch', '{"handle":"' & $sHnd1 & '"}') _WD_Navigate($sSession, "https:\\wdr5.de") Sleep(3000) WinClose("Startseite") Sleep(3000) $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}') If @error > 0 Then ConsoleWrite('>>WD_Window new: error:' & @error & " new window: 'no such window: window was already closed'" & @CRLF) EndFunc ;==>TestWindows Func SetupChrome() _WD_Option('Driver', $sWebDriverFileChrome) _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}' EndFunc ;==>SetupChrome Result: >>WD_Window new: error:0 new window ok __WD_Post: URL=HTTP://127.0.0.1:9515/session/40f35e5cc0be368ee5e59cf6cb6c000a/window; $sData={"handle":"CDwindow-C673FF9062F1C103795815A6E449867E"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_Window: {"value":null}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/40f35e5cc0be368ee5e59cf6cb6c000a/url; $sData={"url":"https:\\wdr5.de"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_Navigate: {"value":null} __WD_Post: URL=HTTP://127.0.0.1:9515/session/40f35e5cc0be368ee5e59cf6cb6c000a/window/new; $sData={"type":"window"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"no such window: window was already closed\n (Session ... __WD_Post ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: window was already closed\n (Session info: chrome=91.0.4472.77)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00D72DB3+2502067]\n\tOrdinal0 [0x00D0C5B1+2082225]\n\tOrdinal0 [0x00C12498+1057944]\n\tOrdinal0 [0x00C08371+1016689]\n\tOrdinal0 [0x00C09345+1020741]\n\tOrdinal0 [0x00C03466+996454]\n\tOrdinal0 [0x00C136A0+1062560]\n\tOrdinal0 [0x00C64272+1393266]\n\tOrdinal0 [0x00C55BEB+1334251]\n\tOrdinal0 [0x00C32174+1188212]\n\tOrdinal0 [0x00C33009+1191945]\n\tGetHandleVerifier [0x00EEEC5C+1511084]\n\tGetHandleVerifier [0x00F98522+2205554]\n\tGetHandleVerifier [0x00DF3393+480739]\n\tGetHandleVerifier [0x00DF2579+477129]\n\tOrdinal0 [0x00D11E5D+2104925]\n\tOrdinal0 [0x00D163F8+2122744]\n\tOrdinal0 [0x00D16537+2123063]\n\tOrdinal0 [0x00D1EE53+2158163]\n\tBaseThreadInitThunk [0x7588FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x777A7A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x777A7A4E+238]\n"}} _WD_Window: {"value":{"error":"no such window","message":"no such window: window was already closed\n (Session ... _WD_Window ==> Webdriver Exception: HTTP status = 404 >>WD_Window new: error:10 new window: 'no such window: window was already closed' Edited June 1, 2021 by HJL
HJL Posted June 1, 2021 Posted June 1, 2021 New script, "no such window" happens with all 3 drivers... expandcollapse popup#include "wd_core.au3" #include "wd_helper.au3" $_WD_DEBUG = $_WD_DEBUG_Info Local $sDesiredCapabilities, $sSession Local $sWebDriverFileChrome = @ScriptDir & "\chromedriver.exe" Local $sWebDriverFileGecko = @ScriptDir & "\geckodriver.exe" Local $sWebDriverFileEdge = @ScriptDir & "\msedgedriver.exe" TestNewWindow("Chrome") TestNewWindow("Gecko") TestNewWindow("Edge") Func TestNewWindow($sBrowser) Local $sHnd1 Switch $sBrowser Case "Chrome" SetupChrome() Case "Gecko" SetupGecko() Case "Edge" SetupEdge() EndSwitch _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}') ConsoleWrite('>>WD_Window ' & $sBrowser & ' new: error:' & @error & ' new window ok' & @CRLF) _WD_Window($sSession, 'Switch', '{"handle":"' & $sHnd1 & '"}') _WD_Navigate($sSession, "https:\\wdr5.de") Sleep(2000) WinClose("Startseite") Sleep(2000) $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}') If @error > 0 Then ConsoleWrite('>>WD_Window ' & $sBrowser & ' new: error:' & @error & ' new window: "no such window"' & @CRLF) MsgBox($MB_TOPMOST, 'Test New Window', $sBrowser & 'Driver' & @CRLF & 'Press OK to continue') _WD_DeleteSession($sSession) _WD_Shutdown() EndFunc ;==>TestWindows Func SetupChrome() _WD_Option('Driver', $sWebDriverFileChrome) _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}' EndFunc ;==>SetupChrome Func SetupGecko() Local $sFuncName = "SetupGecko" _WD_Option('Driver', $sWebDriverFileGecko) _WD_Option('DriverParams', '--log trace --marionette-port 2828') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}' EndFunc Func SetupEdge() _WD_Option('Driver', $sWebDriverFileEdge) _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\msedge.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "' & StringReplace(@ProgramFilesDir, "\", "/") & '/Microsoft/Edge/Application/msedge.exe", "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false}}}}' EndFunc ;==>SetupEdge
Danp2 Posted June 1, 2021 Author Posted June 1, 2021 @HJL From the W3C specs -- Quote If the current top-level browsing context is no longer open, return error with error code no such window. so what you are encountering is by design. You need to switch to another valid window before the command will succeed -- Func TestNewWindow($sBrowser) Local $sHnd1 Switch $sBrowser Case "Chrome" SetupChrome() Case "Gecko" SetupGecko() Case "Edge" SetupEdge() EndSwitch _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) $sHnd1 = _WD_Window($sSession, 'window') $sHnd2 = _WD_Window($sSession, 'new', '{"type":"window"}') ConsoleWrite('>>WD_Window ' & $sBrowser & ' new: error:' & @error & ' new window ok' & @CRLF) _WD_Window($sSession, 'Switch', '{"handle":"' & $sHnd2 & '"}') _WD_Navigate($sSession, "https:\\wdr5.de") Sleep(2000) WinClose("Startseite") Sleep(2000) _WD_Window($sSession, 'Switch', '{"handle":"' & $sHnd1 & '"}') $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}') If @error > 0 Then ConsoleWrite('>>WD_Window ' & $sBrowser & ' new: error:' & @error & ' new window: "no such window"' & @CRLF) MsgBox($MB_TOPMOST, 'Test New Window', $sBrowser & 'Driver' & @CRLF & 'Press OK to continue') _WD_DeleteSession($sSession) _WD_Shutdown() EndFunc ;==>TestWindows Latest Webdriver UDF Release Webdriver Wiki FAQs
HJL Posted June 1, 2021 Posted June 1, 2021 If I close all before opened windows _WD_Window($sSession 'new', '{"type":"window"}') produces always an error? What do I have to do when a user discards all before openened windows? I can check the list of handles (empty in this case) - but what to do then? Again start a session with $sSession = _WD_CreateSession($sDesiredCapabilities)?
Danp2 Posted June 1, 2021 Author Posted June 1, 2021 @HJLYes, you may need to discard the current session and start a new one. Have you checked to see what _WD_Status() returns in this scenario? I suggest that you review this open issue on Github for the Webdriver standards. Yes Latest Webdriver UDF Release Webdriver Wiki FAQs
Recommended Posts