0

enter image description hereso I have the Save dialog box popping up simply using sendkeys. Do I need to switch focus to the save dialog box to interact with it? And ultimately, how would I change the file name, and press enter to save the file?

 bot.FindElementByXPath("//span[@class='iamenutitle'][contains(text(),'Accounts Payable')]").Click
bot.FindElementByCss("[menuitemrefno='126']").Click
'switch to iframe
bot.SwitchToFrame "iamain"
bot.FindElementByName("F_RECORDID").SendKeys "123"
bot.SendKeys bot.Keys.Enter
bot.Wait 500
bot.FindElementByLinkText("View").Click
bot.Wait 500
bot.FindElementByCss("span.buttons.view_attachment").Click
bot.SwitchToNextWindow
bot.SendKeys bot.Keys.Control, "s"

??

Sean
  • 71
  • 2
  • 8
  • 1
    You cannot switch to the dialog (AFAIK). Have you tried an immediate bot.SendKeys bot.Keys.Control, "s" without any attempt to switch? – QHarr Oct 12 '18 at 07:03
  • 1
    Also, I gave an answer to one of your prior questions [here](https://stackoverflow.com/questions/52350740/failing-to-find-an-element-of-this-field-selenium-recognizes) - do you mind feeding back on that answer? – QHarr Oct 12 '18 at 07:04
  • Thank you for sharing your knowledge so generously, you've been extremely helpful. Actually, that switch is--I think also as per your advice--a previous switch to the window containing the PDF I'm trying to download, that had just popped up. Not an attempt to switch to the save dialog box. And that sendkeys does successfully open the save dialog box. – Sean Oct 13 '18 at 18:52
  • Erm... playing catch-up...so did my prior answer work? And did the suggestion above work? – QHarr Oct 13 '18 at 18:54
  • And thank you sir, I did reply to that comment but I think you have to expand to additional comments to see it. – Sean Oct 13 '18 at 18:54
  • I tried putting a bot.sendkeys bot.keys.enter through and it did not save it. I did not think to try another bot.SendKeys bot.Keys.Control, "s". I will try it now if you think that will do it. – Sean Oct 13 '18 at 18:55
  • 1
    Hi, I'm sorry since you solved it in the comments I hadn't even noticed the additional answer. I just tried it and it worked brilliantly! Thank you. Seems to be faster. – Sean Oct 13 '18 at 19:07
  • 1
    It is faster. CSS selectors are fast. Now did you try SendKeys for this? – QHarr Oct 13 '18 at 19:10
  • I did, I wasn't successful however. Any other ideas on how to get involved with this save dialog box? So close and yet so far... lol – Sean Oct 13 '18 at 19:18
  • Lol...Let me have a think but as I can't test it is unlikely I can help much. It looks like the pop up window is file explorer which may mean you can look for an API call that will allow you to grab that window handle. – QHarr Oct 13 '18 at 19:19
  • Is there an URL associated with the file download? – QHarr Oct 13 '18 at 19:22
  • yes.. a windows API. that is probably what I'm after. this is off the cloud accounting software website intacct.com. I'm not sure how I would suss out if there is a url that would pinpoint this download. it would be behind a password unfortunately. – Sean Oct 13 '18 at 19:50
  • I assume span.buttons.view_attachment is for the element associated with the download - when you inspect it, is there an URL in the HTML? – QHarr Oct 13 '18 at 19:52
  • I see people discussing auto save settings.. that's one possible workaround, although I'd miss the opportunity of assigning a descriptive file name to the download.. might be able to be done later though. Another possible workaround I might try if all else fails is screenshotting the window containing the PDF, as an image file will suffice. – Sean Oct 13 '18 at 19:52
  • Maybe something here: https://stackoverflow.com/a/34858998/6241235 Or at least along these lines. These are the standard APIs to use. Also, see: https://learn.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-findwindowa and https://learn.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-findwindowexa – QHarr Oct 13 '18 at 19:53
  • Hello again, sir. So I found out there's supposedly a way to set preferences to simply download without a Save As prompt... I can do it manually... but of course I'd have to do that every time I reset the bot. SO... drumroll... https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup This site contains all the bot.SetPreferences methods. And going to the downloads, you can see there's one to turn off the prompt. I have done so, but am still hitting a wall. Happy using, and if you try one, let me know if you have any success. I haven't yet. New post coming. – Sean Nov 04 '18 at 20:01
  • Very interesting. Thanks for letting me know. – QHarr Nov 04 '18 at 20:17

0 Answers0