selenium of python (3.3.1)实现关闭浏览器页签功能
1.打开新页签后关掉当前页签
chrome=webdriver.Chrome()
chrome.close();
2.打开新页签后关掉新页签
win=chrome.window_handles #窗口数声明变量
time.sleep(3) #等待时间,如需用需 import time
for w in win: #w 为遍历到的窗口
if w == chrome.current_window_handle: # 如果遍历到当前窗口继续
continue
# chrome.switch_to_window(w)
chrome.switch_to.window(w) #遍历到新窗口则关掉
chrome.close()