美文网首页selenium + python专题
selenium webdriver基于Python系列文章之多

selenium webdriver基于Python系列文章之多

作者: 七月尾巴_葵花 | 来源:发表于2017-03-19 10:21 被阅读48次

def func():

a = ff.find_element_by_tag_name("a")

# 保存原始窗口,window_handlers是目前wd打开的所有窗口的句柄列表

prev = ff.window_handles[-1]

# 点击超链接(targe="_blank")后,浏览器新窗口被激活

a.click()

# 保存新窗口

new = ff.window_handles[-1]

# 切换到原始窗口

sleep(2)

ff.switch_to_window(prev)

print "Switch to prev success"

sleep(2)

# 切换到新窗口

ff.switch_to_window(new)

print "Switch to new success"

相关文章

网友评论

    本文标题:selenium webdriver基于Python系列文章之多

    本文链接:https://www.haomeiwen.com/subject/dxeunttx.html