# 获取当前的页面窗口 first_handle = brower.current_window_handle handles = brower.window_handles for i in handles: if i != first_handle: brower.close() # 关闭当前窗口 brower.switch_to.window(i) brower.find_element_by_class_name("button1").click() # 点击提交按钮,提交数据 time.sleep(2)