多窗口处理三种方法
导包,实例化浏览器
from selenium import webdriver
fx=webdriver.Firefox()
方法一
fx.switch_to.window(fx.window_handles[1])
方法二
for handle in fx.window_handles:
fx.switch_to.window(handle)
方法三
定位初始窗口句柄
current_handle=fx.current_window_handle
所有窗口句柄
all_hndles=fx.window_handles
for i in all_handles:
if i !=current_handle:
fx.switch_to.window(i)
python3 打开页面后多窗口处理三种方法
猜你喜欢
转载自www.cnblogs.com/jackzz/p/9125709.html
今日推荐
周排行