How do I switch focus to a new window using Selenium VBA?

跟風遠走 提交于 2020-04-30 07:01:06

问题


So, I know how to find the name of the active window

currentWindow = bot.Send("GET", "/window_handle")
bot.SwitchToWindowByName currentWindow

Is there a way to get the name of the inactive window that I just popped up?

I tried going to console and typing window.name and got "" Also tried using window.document.name and got "download.phtml", but

bot.SwitchToWindowByName download.phtml

gave me a Runtime 424 Object Required error.

Picture of the new window (on the right)


回答1:


Explicitly with

bot.SwitchToWindowByTitle "Title"  '<==Make sure it is the actual Title you are using of the Window

If it has just popped up you may also try

bot.SwitchToNextWindow


来源:https://stackoverflow.com/questions/52397268/how-do-i-switch-focus-to-a-new-window-using-selenium-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!