AttilaP Posted November 24, 2020 Share Posted November 24, 2020 I tried this: _WD_ExecuteCdpCommand($sSession,'Page.setDownloadBehavior','{"behavior": "allow", "downloadPath": "D:/"}') In the log I can see it has been processed: Quote [1606202783.862][INFO]: [f2d060d6c8d3b639b77b63f654790aea] COMMAND ExecuteCDP { "cmd": "Page.setDownloadBehavior", "params": "{\"behavior\": \"allow\", \"downloadPath\": \"D:/\"}" } Nevertheless the file is still downloaded to the default folder. Also tried with _WD_ExecuteCdpCommand($sSession,'Page.setDownloadBehavior',"{behavior: 'allow', downloadPath: 'D:/'}") In the log it was Quote [1606203265.913][INFO]: [e567bffe6965b2da3dde1eea61bd8945] COMMAND ExecuteCDP { "cmd": "Page.setDownloadBehavior", "params": "{behavior: 'allow', downloadPath: 'D:/'}" } Still, the file was not in the D:/ folder. Link to comment Share on other sites More sharing options...
TheDcoder Posted November 24, 2020 Share Posted November 24, 2020 (edited) You should be able to use _WD_ExecuteCdpCommand with the Page.setDownloadBehavior command as shown in the python script. I see that this command is deprecated so it may or may not work in the latest version of Chrome. Edit: Did not notice @AttilaP's reply in this page as my notification took me to the previous page. Edited November 24, 2020 by TheDcoder 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...
Danp2 Posted November 24, 2020 Author Share Posted November 24, 2020 @AttilaP It might help if you post a reproducer so that we can fully see what you're doing. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Siwa Posted November 26, 2020 Share Posted November 26, 2020 another question, how can I add this : Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("credentials_enable_service", false); prefs.put("profile.password_manager_enabled", false); options.setExperimentalOption("prefs", prefs); I want to disable save password dialoge. Link to comment Share on other sites More sharing options...
Danp2 Posted November 26, 2020 Author Share Posted November 26, 2020 @Siwa Use the forum's search feature and you should be able to a figure it out. Siwa 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Siwa Posted November 26, 2020 Share Posted November 26, 2020 (edited) Sorry I searched google, but it did no search deep, when I searched with forum's search, it came up with many answers. for future references for those looking for disabling save password dialog within chrome, they must add this : "prefs": {"credentials_enable_service": false, "profile.password_manager_enabled": false}, Edited November 26, 2020 by Siwa Danp2 1 Link to comment Share on other sites More sharing options...
AttilaP Posted December 1, 2020 Share Posted December 1, 2020 On 11/24/2020 at 2:11 PM, Danp2 said: @AttilaP It might help if you post a reproducer so that we can fully see what you're doing. Wish I could.. But the site has credentials, and I think that is the problem. _WD_DownloadFile has nothing to do with the browser itself, it is calling InetRead(). So the cookies are not passed, therefore I got the logon screen back. But it is still strange that when I use standard navigation, the file is downloaded - but into the standard downloads folder, not to the one I specify. Link to comment Share on other sites More sharing options...
TheDcoder Posted December 1, 2020 Share Posted December 1, 2020 Have you tried the `download.default_directory` Chrome option? You can set a default path for downloads and any downloads will go into that folder. AttilaP 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...
Danp2 Posted December 1, 2020 Author Share Posted December 1, 2020 @AttilaP FWIW, a reproducer just needs to be code that we can run to observe the problem. It can use any site, as long as the issue can be seen when running the code. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
AttilaP Posted December 1, 2020 Share Posted December 1, 2020 TheDcoder: thanks, that solved the problem. Danp2: I could not find a page which requires login and offers a file to be downloaded this way. With setting download.default_directory, it works flawlessly. Thank you both! TheDcoder 1 Link to comment Share on other sites More sharing options...
Siwa Posted December 4, 2020 Share Posted December 4, 2020 (edited) Just another question, I want to add a timeout to my automation, so if the entire code is stuck at a point, then it will exit after a defined time ( like 2 minutes for example ), so the code can go on. ( My entire code checks for lots of elements and navigates to different pages) The only way I can think of is he use of TimeDiff. But if then I have to do it during each action performed, so it will be confusing and a lot of unnecessary coding. I came across _WD_Timeouts but I don't know it's function and what it does even I read the UDF part too. What are my solutions besides TimeDiff, for my entire script ? ( combination of "Page load timeout" and "Script timeout" ) Edited December 4, 2020 by Siwa Link to comment Share on other sites More sharing options...
CYCho Posted December 4, 2020 Share Posted December 4, 2020 (edited) @Siwa AdlibRegister ( "function" [, time = 250] ) is available just for this purpose. You should carefully read the Remarks of the Help file: The adlib function should be kept simple as it is executed often and during this time the main script is paused. AdlibRegister("MyExit") $h = TimerInit() While 1 Sleep(20) WEnd Func MyExit() If TimerDiff($h) > 5000 Then Exit EndFunc Edited December 4, 2020 by CYCho Siwa 1 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
Danp2 Posted December 4, 2020 Author Share Posted December 4, 2020 @Siwa Your script shouldn't get "stuck" as long as you've included appropriate error checking. Can you provide an example where this is occurring? FWIW, you can read more about the webdriver timeouts here. Be advised that the term "script" is referring to javascript, not AutoIt. 😉 Siwa 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Siwa Posted December 4, 2020 Share Posted December 4, 2020 (edited) @CYCho Adlib will be useful if no other option is not available. I prefer to do it inside webdriver itself or the UDF. @Danp2 an example is a simple code like : $All_Cases = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='dataTable_paginator_top']/span[1]") or any other code, when the page is not loaded fully for a reason like net hiccups or sudden and momentarily net disconnecting's and the page try's to load for a long time, or is stuck at the spinning circle for ever. I want to be able to stop and repeat the process if it takes longer than 2 - 3 minutes to finish (obviously there is something going wrong), or load the page or an autoit script to proceed to the next step. Edited December 4, 2020 by Siwa Link to comment Share on other sites More sharing options...
Danp2 Posted December 4, 2020 Author Share Posted December 4, 2020 @Siwa OIC. With that in mind you benefit by using _WD_Timeouts to adjust the default timeout values. You may want to check out _WD_LoadWait. Finally, you can also look into adjusting the pageLoadStrategy setting, which has previously been discussed in this forum. Siwa 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CYCho Posted December 11, 2020 Share Posted December 11, 2020 (edited) Hi @Danp2, I am testing if I can migrate my webdriver codes based on chromedriver to msedgedriver. But I am stuck in my first step. When I run the following code, the Edge browser displays a modal dialogue box asking me if I want to sync my profile. This dialogue is not detected by _WD_Alert and "unhandledPromptBehavior": "ignore" clause in the capabilities does not have any effect. Please help me on how I can handle this dialogue box. #include "wd_core.au3" #include "wd_helper.au3" _WD_Option('Driver', @ScriptDir & '\msedgedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\msedge.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _ '"ms:edgeOptions": {"excludeSwitches": ["enable-automation"], ' & _ '"useAutomationExtension": false, "args": ["start-maximized"]}}}}' $_WD_DEBUG = $_WD_Debug_Info ; None ; Info _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) Sleep(1000) _WD_Navigate($sSession, "https://www.autoitscript.com") The SciTE console looks like this: >Running:(3.3.14.5):C:\AutoIt3\autoit3.exe "D:\EdgeDriver\EdgeTest.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. _WD_IsLatestRelease: True _WD_IsLatestRelease ==> Success _WDStartup: OS: WIN_10 WIN32_NT 19042 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.3.1.0 (Up to date) _WDStartup: WinHTTP: 1.6.4.2 _WDStartup: Driver: D:\EdgeDriver\msedgedriver.exe _WDStartup: Params: --verbose --log-path="D:\EdgeDriver\msedge.log" _WDStartup: Port: 9515 __WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", "ms:edgeOptions": {"excludeSwitches": ["enable-automation"], "useAutomationExtension": false, "args": ["start-maximized"]}}}} __WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"msedge","browserVersion":"87.0.... _WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"msedge","browserVersion":"87.0.664.57","ms:edgeOptions":{"debuggerAddress":"localhost:61768"},"msedge":{"msedgedriverVersion":"86.0.622.68 (48323fbb4a373465cd5175c727ef318acbd46c33)","userDataDir":"C:\\Users\\CYCho\\AppData\\Local\\Temp\\scoped_dir13840_1521216339"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"ignore","webauthn:virtualAuthenticators":true},"sessionId":"9e38fc90e6147bc2c9916ab2a74efdb6"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/9e38fc90e6147bc2c9916ab2a74efdb6/url; $sData={"url":"https://www.autoitscript.com"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_Navigate: {"value":null} Edited December 11, 2020 by CYCho zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
abodilsen Posted December 11, 2020 Share Posted December 11, 2020 Hi all. Im new to AutoIT and the webdriver UDF so bear with me I have tried to search a bit in the forum but have not succeeded in finding something that works for me. I am trying to open a website and respond to the "popup" by clicking accept. My strategy has been to first identify the element by: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select[@name='agree']") And then click the button by _WD_ElementAction($sSession,$sElement,'click') But it seems like the webdriver cannot find the element _WDStartup: OS: WIN_10 WIN32_NT 18363 _WDStartup: AutoIt: 3.3.14.5 _WDStartup: WD.au3: 0.2.0.5 _WDStartup: WinHTTP: 1.6.4.1 _WDStartup: Driver: S:\AutoITInclude\chromedriver.exe _WDStartup: Params: --verbose --log-path="S:\AutoIT_tutorial\chrome.log" _WDStartup: Port: 9515 __WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}} __WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"87.0.4280.88","chrome":{"chromedriverVersion":"87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761})","userDataDir":"C:\\Users\\abodi\\AppData\\Local\\Temp\\scoped_dir51416_1944427882"},"goog:chromeOptions":{"debuggerAddress":"localhost:59821"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:virtualAuthenticators":true},"sessionId":"2afc622222c767b8fbab1613c58f938d"}} _WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"87.0.4280.88","chrome":{"chromedriverVersion":"87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761})","userDataDir":"C:\\Users\\abodi\\AppData\\Local\\Temp\\scoped_dir51416_1944427882"},"goog:chromeOptions":{"debuggerAddress":"localhost:59821"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:virtualAuthenticators":true},"sessionId":"2afc622222c767b8fbab1613c58f938d"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/2afc622222c767b8fbab1613c58f938d/url; $sData={"url":"http://finance.yahoo.com"} __WD_Post: StatusCode=200; ResponseText={"value":null} _WD_Navigate: {"value":null} __WD_Post: URL=HTTP://127.0.0.1:9515/session/2afc622222c767b8fbab1613c58f938d/element; $sData={"using":"xpath","value":"//select[@name='agree']"} __WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//select[@name='agree']\"}\n (Session info: chrome=87.0.4280.88)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0106C0C3+3326147]\n\tOrdinal0 [0x00F50851+2164817]\n\tOrdinal0 [0x00DD7298+619160]\n\tOrdinal0 [0x00D5C070+114800]\n\tOrdinal0 [0x00D7FC42+261186]\n\tOrdinal0 [0x00D71A2A+203306]\n\tOrdinal0 [0x00D7E559+255321]\n\tOrdinal0 [0x00D7189B+202907]\n\tOrdinal0 [0x00D53DF4+81396]\n\tOrdinal0 [0x00D54DEE+85486]\n\tOrdinal0 [0x00D54D79+85369]\n\tOrdinal0 [0x00F685DC+2262492]\n\tGetHandleVerifier [0x011F2874+1487204]\n\tGetHandleVerifier [0x011F23CD+1486013]\n\tGetHandleVerifier [0x011FA368+1518680]\n\tGetHandleVerifier [0x011F2F4E+1488958]\n\tOrdinal0 [0x00F5ED0D+2223373]\n\tOrdinal0 [0x00F6A12B+2269483]\n\tOrdinal0 [0x00F6A26F+2269807]\n\tOrdinal0 [0x00F7ECB8+2354360]\n\tBaseThreadInitThunk [0x774A6359+25]\n\tRtlGetAppContainerNamedObjectPath [0x775F8944+228]\n\tRtlGetAppContainerNamedObjectPath [0x775F8914+180]\n"}} _WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//select[@name='agree']\"}\n (Session info: chrome=87.0.4280.88)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0106C0C3+3326147]\n\tOrdinal0 [0x00F50851+2164817]\n\tOrdinal0 [0x00DD7298+619160]\n\tOrdinal0 [0x00D5C070+114800]\n\tOrdinal0 [0x00D7FC42+261186]\n\tOrdinal0 [0x00D71A2A+203306]\n\tOrdinal0 [0x00D7E559+255321]\n\tOrdinal0 [0x00D7189B+202907]\n\tOrdinal0 [0x00D53DF4+81396]\n\tOrdinal0 [0x00D54DEE+85486]\n\tOrdinal0 [0x00D54D79+85369]\n\tOrdinal0 [0x00F685DC+2262492]\n\tGetHandleVerifier [0x011F2874+1487204]\n\tGetHandleVerifier [0x011F23CD+1486013]\n\tGetHandleVerifier [0x011FA368+1518680]\n\tGetHandleVerifier [0x011F2F4E+1488958]\n\tOrdinal0 [0x00F5ED0D+2223373]\n\tOrdinal0 [0x00F6A12B+2269483]\n\tOrdinal0 [0x00F6A26F+2269807]\n\tOrdinal0 [0x00F7ECB8+2354360]\n\tBaseThreadInitThunk [0x774A6359+25]\n\tRtlGetAppContainerNamedObjectPath [0x775F8944+228]\n\tRtlGetAppContainerNamedObjectPath [0x775F8914+180]\n"}} _WD_FindElement ==> No match: HTTP status = 404 "S:\AutoIT_tutorial\FindTrickerNames.au3" (95) : ==> Error parsing function call.: _WD_Shutdown Link to comment Share on other sites More sharing options...
Danp2 Posted December 11, 2020 Author Share Posted December 11, 2020 1 hour ago, CYCho said: When I run the following code, the Edge browser displays a modal dialogue box asking me if I want to sync my profile. I ran your code, but didn't encounter this dialog. Suggest that you try to identify what is causing this to appear. It likely won't have any effect on this issue, but your msedgedriver appears to be out of date. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted December 11, 2020 Author Share Posted December 11, 2020 @abodilsen Have you tried using _WD_Alert to see if it detects this popup? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CYCho Posted December 11, 2020 Share Posted December 11, 2020 (edited) 1 hour ago, Danp2 said: I ran your code, but didn't encounter this dialog. Suggest that you try to identify what is causing this to appear. It likely won't have any effect on this issue, but your msedgedriver appears to be out of date. I updated both Edge and msedgedriver to the latest matching versions and, as you expected, it was not an issue. The dialogue box appears when the session is created before navigating to a web site. Until I find an answer, I will just issue a Send("{enter}") command, which basically accepts the prompt, and go on with further tests. Please let me know if you come across with a solution. Edited December 11, 2020 by CYCho zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
Recommended Posts