stamyuka Posted December 14, 2020 Share Posted December 14, 2020 Hi @Danp2, I just noticed when added below parameters into Chrome options, it seems like if there's a SSL certificate warning, _WD_navigate() function won't return until user manually clicks Advanced -> proceed to 'website'. "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false Therefore, below code to automate skipping cert warning page won't work. Without these Chrome options, _WD_navigate() will respond even though SSL cert warning page is presented, and below code works. But without these options, Chrome will display: "Chrome is being controlled by automated test software". Just want to check with you if there's a way to still automate skipping the SSL cert warning page while the above two Chrome options are specified? Local Const $advancedElementSelector = "//button[@id='details-button']" Local Const $proceedElementSelector = "//a[@id='proceed-link']" Local Const $certWarningString = "Your connection is not private" _WD_Navigate($sSession, "https://www.samplewebsite.com") If StringInStr(_WD_GetSource($sSession), $certWarningString) > 0 Then _WD_LoadWait($sSession, 0, 5000) $advancedElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $advancedElementSelector) $proceedElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $proceedElementSelector) _WD_ElementAction($sSession, $advancedElement, 'click') _WD_ElementAction($sSession, $proceedElement, 'click') EndIf Link to comment Share on other sites More sharing options...
cdeb Posted December 14, 2020 Share Posted December 14, 2020 Access to youtubestudio and authentication I'm trying to use WebDriver to access youtube Studio to automate some processes but I have some authentication problems I run a _WD_Navigate() and pause with a MsgBox to login on the browser (Sign in to continue to YouTube) #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession SetupGecko() _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit -1 EndIf $sSession = _WD_CreateSession($sDesiredCapabilities) If @error = $_WD_ERROR_Success Then ConsoleWrite("@error: " & @error & @CRLF) EndIf Local $url ="https://studio.youtube.com" _WD_Navigate($sSession, $url) MsgBox(16, "info", "login...") Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}' EndFunc view attachment: login.png but after entering the user the following message appears view attachment: no_access.png Quote Couldn't sign you in This browser or app may not be secure. Learn more Try using a different browser. If you're already using a supported browser, you can refresh your screen and try again to sign in. How can I overcome this obstacle? Link to comment Share on other sites More sharing options...
Danp2 Posted December 14, 2020 Author Share Posted December 14, 2020 @stamyuka You might want to try adding the following to your chromeOptions section -- "acceptInsecureCerts":true Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted December 14, 2020 Author Share Posted December 14, 2020 @yazanabbass11 No idea what you are trying to say. Care to elaborate? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted December 14, 2020 Author Share Posted December 14, 2020 39 minutes ago, cdeb said: How can I overcome this obstacle? This is a login restriction implemented by Google. You can find a few suggested workarounds if you search the web. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
stamyuka Posted December 14, 2020 Share Posted December 14, 2020 Thank you very much @Danp2. One last question I have: seems like when using the latest version of UDF, there are around 15-20 seconds delay of launching the chrome driver using _WD_Startup(). When the code enters _WD_Startup(), it takes around 15 - 20 seconds for the chrome driver to appear and the script continue to next function. Is this expected? Link to comment Share on other sites More sharing options...
Danp2 Posted December 14, 2020 Author Share Posted December 14, 2020 @stamyuka No, a 15+ second delay isn't normal. Can't say that I've encounter this. For me, it's like a second or two. Have you checked chrome.log to try to identify where the delay is occurring? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
stamyuka Posted December 14, 2020 Share Posted December 14, 2020 @Danp2, I figured out the root cause of the 15+ second delay for me, it's because below two lines in Func _WD_Startup(). The server I'm running the script does not have Internet connection, and the delay is probably caused by waiting for HTTP response until timeout I guess. $sFunction = "_WD_IsLatestRelease" $lLatest = Call($sFunction) Link to comment Share on other sites More sharing options...
Danp2 Posted December 14, 2020 Author Share Posted December 14, 2020 @stamyuka Gotcha. There is probably a way to reduce or eliminate the delay, but I don't know of one off hand. How does the rest of the script function without an internet connection? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
stamyuka Posted December 15, 2020 Share Posted December 15, 2020 @Danp2, I think the rest of the script functions are working pretty well for me, I only noticed this one delay during start-up. 😁 I added $WD_DEBUG = $WD_DEBUG_None before calling _WD_Startup(), and it bypasses the version checks, thus resolves the delay as well. Also looks like when run it with $WD_DEBUG_None, the driver console will not be displayed, it will be just a process running in background, which is also better for the users as they don't need to see the console. 😝 For the functions I have used so far, they are all working well. Link to comment Share on other sites More sharing options...
Danp2 Posted December 15, 2020 Author Share Posted December 15, 2020 @stamyuka This is covered in the Wiki FAQ section (see my sig) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Harutyun Posted December 16, 2020 Share Posted December 16, 2020 On 12/14/2020 at 8:41 PM, Danp2 said: "acceptInsecureCerts":true Hello @Danp2 , I have tried it, but don't work. Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":[' & """start-maximized""," & " ""disable-infobars""" & "" & '], "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false, "acceptInsecureCerts":true}}}}' EndFunc What is going wrong here? Please help me) Link to comment Share on other sites More sharing options...
Danp2 Posted December 16, 2020 Author Share Posted December 16, 2020 @Harutyun Sorry, but "doesn't work" isn't a sufficient description of whatever is going wrong. 🙁 Suggest that you move the "acceptInsecureCerts":true outside of your goog:chromeOptions section. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Harutyun Posted December 16, 2020 Share Posted December 16, 2020 4 hours ago, Danp2 said: Suggest that you move the "acceptInsecureCerts":true outside of your goog:chromeOptions section. Thanks @Danp2, it helps to avoid that problem with Chrome SSL certificate warning (Your connection is not private). I put "acceptInsecureCerts":true before goog:chromeOptions. I try it on Edge webdriver function too, in this case putting before ms:edgeOptions and it works. Thanks again. Link to comment Share on other sites More sharing options...
abodilsen Posted December 17, 2020 Share Posted December 17, 2020 Hi all. Is AutoIT able to catch exceptions from the webdriver like the one below ? _WD_ElementAction: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Ses... _WD_ElementAction ==> Webdriver Exception: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n (Session info: chrome=87.0.4280.88)","stacktrace":"Backtrace:\n\tOrdinal0 [0x012EC0C3+3326147]\n\tOrdinal0 [0x011D0851+2164817]\n\tOrdinal0 [0x01057298+619160]\n\tOrdinal0 [0x00FDB8C3+112835]\n\tOrdinal0 [0x00FD8C14+101396]\n\tOrdinal0 [0x00FF19F3+203251]\n\tOrdinal0 [0x00FD5A16+88598]\n\tOrdinal0 [0x00FF1ADA+203482]\n\tOrdinal0 [0x00FFE559+255321]\n\tOrdinal0 [0x00FF189B+202907]\n\tOrdinal0 [0x00FD3DF4+81396]\n\tOrdinal0 [0x00FD4DEE+85486]\n\tOrdinal0 [0x00FD4D79+85369]\n\tOrdinal0 [0x011E85DC+2262492]\n\tGetHandleVerifier [0x01472874+1487204]\n\tGetHandleVerifier [0x014723CD+1486013]\n\tGetHandleVerifier [0x0147A368+1518680]\n\tGetHandleVerifier [0x01472F4E+1488958]\n\tOrdinal0 [0x011DED0D+2223373]\n\tOrdinal0 [0x011EA12B+2269483]\n\tOrdinal0 [0x011EA26F+2269807]\n\tOrdinal0 [0x011FECB8+2354360]\n\tBaseThreadInitThunk [0x77B76359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77CB8944+228]\n\tRtlGetAppContainerNamedObjectPath [0x77CB8914+180]\n"}} I have done some searching in this forum and have not been able to find a good solution. Link to comment Share on other sites More sharing options...
Danp2 Posted December 17, 2020 Author Share Posted December 17, 2020 @abodilsen Yes... you should check the value of @error to detect success / failure of the UDF function. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted December 17, 2020 Share Posted December 17, 2020 @Danp2 Do you have a solution for the scoped_dir* folders created in @TempDir each and every time I run WebDriver ? Whether it is Chrome or Edge, a folder is created and not deleted even if I end my script with : _WD_DeleteSession($sSession) _WD_Shutdown() Searching for a solution, most rely on deleting them periodically. But in here, someone says that using Driver.quit() method should delete those folders. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Danp2 Posted December 17, 2020 Author Share Posted December 17, 2020 (edited) @Nine Haven't looked into it. It's likely that the __WD_CloseDriver function needs to be revised to allow the webdriver to exit in a more "natural" manner. FWIW, I think the Driver.quit() bit is only applicable to Selenium. Edit: Just ran a quick test and the directories were removed when the session is closed with _WD_DeleteSession Edited December 17, 2020 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted December 17, 2020 Share Posted December 17, 2020 (edited) Ok, thanks, let me know if you find a solution, cause it is growing fast when you launch multiple scripts. Quote directories were removed when the session is closed with _WD_DeleteSession Not for me... Edited December 17, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Danp2 Posted December 17, 2020 Author Share Posted December 17, 2020 1 hour ago, Nine said: Not for me... This is the simple script that I was using to test -- expandcollapse popup#include "wd_core.au3" #include <File.au3> Local $sDesiredCapabilities, $sSession CheckTemp() SetupChrome() _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit -1 EndIf $sSession = _WD_CreateSession($sDesiredCapabilities) Sleep(2000) _WD_DeleteSession($sSession) _WD_Shutdown() CheckTemp() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') _WD_Option('DriverClose', False) $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}' EndFunc Func CheckTemp() Local $aMatches = _FileListToArray(@TempDir, "scoped_dir*", $FLTA_FOLDERS) Switch @error Case 0 ConsoleWrite($aMatches[0] & " matching directories" & @CRLF) Case 4 ConsoleWrite("No matching directories!" & @CRLF) Case Else ConsoleWrite("@error=" & @error & @CRLF) EndSwitch EndFunc Generally, the directories get removed for me. After running this around 10-15 times, I did experience one left over directory. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts