1. 程式人生 > >selenium +python 如何得到彈出視窗

selenium +python 如何得到彈出視窗

# 獲取當前的頁面視窗
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)

參考文章連結: https://www.cnblogs.com/jane0912/p/4177779.html