iframe 处理

 1 # -*- coding:utf-8 -*-
 2 """
 3 iframe 处理
 4 """
 5 
 6 from selenium import webdriver
 7 
 8 driver = webdriver.Ie()
 9 driver.get(r'F:\电子书\selenium\Selenium Testing Tools Cookbook(中文)\demo\iframe\iframe.html')
10 #首先定位父窗
11 driver.switch_to_frame('left')
12 #获得 iframe元素
13 weiboIframe = driver.find_element_by_tag_name('iframe')
14 #获得 iframe 窗口
15 driver.switch_to_frame(weiboIframe)
16 
17 actualText = driver.find_element_by_link_text("新浪微博").text
18 
19 print actualText
20 
21 driver.switch_to_default_content()

 

posted @ 2013-07-14 23:21  Roger|  阅读(191)  评论(0编辑  收藏  举报