F#顶棚关闭弹出窗口
我正在测试一个有弹出窗口的网页。是否有人知道是否有一种方法可以通过天篷关闭弹出窗口F#顶棚关闭弹出窗口,f#,canopy-web-testing,F#,Canopy Web Testing,我正在测试一个有弹出窗口的网页。是否有人知道是否有一种方法可以通过天篷关闭弹出窗口 否则,我想这是一种用硒来处理的情况?这并不太难。基本算法是: 在离开主测试线程之前获取窗口句柄 运行将弹出新窗口的代码 把那扇窗户搬到前面去 在弹出窗口上运行browser.Close() 切换回原始窗口 代码: let origWindow = browser.CurrentWindowHandle // do something to open another window // make the new w
否则,我想这是一种用硒来处理的情况?这并不太难。基本算法是:
let origWindow = browser.CurrentWindowHandle
// do something to open another window
// make the new window the focus of tests
let newWindow = browser.WindowHandles |> Seq.find (fun w -> w <> origWindow )
browser.SwitchTo().Window(newWindow) |> ignore
// optionally do asserts on the contents of the new window
// close the new window
browser.Close()
// switch back to the original window
browser.SwitchTo().Window(origWindow) |> ignore
你必须用硒来处理它。我还没有为它编写帮助函数。”browser'是webdriver的实例。
let switchToWindow window =
browser.SwitchTo().Window(window) |> ignore
let getOtherWindow currentWindow =
browser.WindowHandles |> Seq.find (fun w -> w <> currentWindow)
let switchToOtherWindow currentWindow =
switchToWindow (getOtherWindow currentWindow) |> ignore
let closeOtherWindow currentWindow =
switchToOtherWindow currentWindow
browser.Close()
let origWindow = browser.CurrentWindowHandle
// do something to open another window
// make the new window the focus of tests
switchToOtherWindow origWindow
// optionally do asserts on the contents of the new window
// close the new window
closeOtherWindow origWindow
// switch back to the original window
switchToWindow origWindow