uibobo
V2EX  ›  问与答

[求助!]selenium 切换窗口时无法捕获 alert

  •  
  •   uibobo · Nov 16, 2020 · 844 views
    This topic created in 2005 days ago, the information mentioned may be changed or developed.

    场景:点击跳转到新页面,进入新页面时就会弹出一个 alert 。想关闭新页面这个 alert ;

    是不是在执行 switchTo().window 之前这个 alert 已经加载,无法捕获到?

    WebDriver newDriver = driver.switchTo().window(handle);//切换到新的窗口 Alert alert = newDriver.switchTo().alert(); //程序停留在这行 alert.accept();

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5457 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 92ms · UTC 05:52 · PVG 13:52 · LAX 22:52 · JFK 01:52
    ♥ Do have faith in what you're doing.