#WebDriver 支持在指定的窗口间移动,方法为switch_to_window:
driver.switch_to_window("windowName")
#现在所有的driver的调用都会指向这个给定的窗口,但是我们怎么知道窗口的名字是什么呢?可以看一看打开这个窗口的javascript脚本或者link链接:
#<a href="somewhere.html" target="windowName">Click here to open a new window</a>
#或者,你可以传一个window handle给switch_to_window()方法,它就可以像这样迭代每一个打开的窗口:
for handle in driver.window_handles:
driver.switch_to_window(handle)
selenium在窗口之间移动
最新推荐文章于 2023-10-09 21:17:08 发布