【问题标题】:How do I switch focus to a new window using Selenium VBA?如何使用 Selenium VBA 将焦点切换到新窗口?
【发布时间】:2019-02-23 02:54:35
【问题描述】:

所以,我知道如何找到活动窗口的名称

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

有没有办法获取我刚刚弹出的非活动窗口的名称?

我尝试去控制台并输入 window.name 并得到“” 也尝试使用 window.document.name 并得到“download.phtml”,但是

bot.SwitchToWindowByName download.phtml

给了我一个 Runtime 424 Object Required 错误。

Picture of the new window (on the right)

【问题讨论】:

    标签: vba selenium window selenium-chromedriver new-window


    【解决方案1】:

    明确地用

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

    如果刚刚弹出你也可以试试

    bot.SwitchToNextWindow
    

    【讨论】:

    • 选择.SwitchToNextWindow后如何切换回默认窗口?我尝试使用 .SwitchToDefaultWindow,但 vba 无法识别该命令 @QHarr。
    • 你知道这个。 @MITHU。切换到默认内容
    • 那是我的第一次尝试。我想这个特定的命令是针对 iframe 的。也许我错了。但是,使用.SwitchtodefaultcontentSwitchToDefaultWindow 会导致error
    • 我使用这个链接https://www.pinterest.com/然后点击log in然后使用Continue with Google选项。使用google登录后,我使用另一个链接查看我是否已登录https://www.google.com/retail/solutions/merchant-center/。谢谢。
    • 是的,我知道。你几天前提到过。
    猜你喜欢
    • 2016-11-14
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-11
    • 2015-05-01
    • 2019-01-10
    • 1970-01-01
    相关资源
    最近更新 更多