我有一个程序,它打开了一个PDF文件并且我想要保存这个文件。我原本认为使用SetPreferences可以绕过SaveAs对话框,但是现在又弹出了对话框。有没有人成功地使用SetPreferences来关闭SaveAs对话框呢?
我是不是把这些选项设置放错了位置?我的理解是在启动机器人之前就应该设置。
Sub CompanyName()
Dim bot As New Selenium.WebDriver
MyFolder = ThisWorkbook.Path
bot.SetPreference "download.default_directory", MyFolder
bot.SetPreference "download.directory_upgrade", True
bot.SetPreference "download.prompt_for_download", False
bot.Start "Chrome", "https://www.intacct.com/ia/acct/login.phtml?[![enter image description here][1]][1]_ga=2.13247287.1007588550.1536894830-1229002215.1536894830"
bot.Get "/"
bot.FindElementById("company").SendKeys "Company ID"
bot.Wait 500
bot.FindElementById("login").SendKeys "Username"
bot.Wait 500
bot.FindElementById("passwd").SendKeys "Password"
bot.Wait 500
bot.FindElementById("retbutton").Click
Stop
'bot.SwitchToParentFrame
Dim menuitem As WebElement
Set menuitem = bot.FindElementByCss("#mainmenu > div > div:nth-child(7) > div.iamenutitlewrapper > span")
bot.Actions.MoveToElement(menuitem).Perform
bot.FindElementByXPath("//span[@class='iamenutitle'][contains(text(),'Accounts Payable')]").Click
bot.FindElementByCss("#mainmenu > div > div:nth-child(7) > div.iamenu.mega.setup-closed > div > div > table > tbody > tr:nth-child(5) > td:nth-child(2) > span:nth-child(2)").Click
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"