#coding=UTF-8
from selenium import webdriver
import time
if __name__ == '__main__':
driver = webdriver.Firefox(executable_path='D:\Mozilla Firefox')
driver.maximize_window()
driver.get('file:///E:/selenium_study/demo.html')
time.sleep(2)
#iframe
#进入嵌套的页面,这里aa是iframe的name
driver.switch_to_frame('aa')
#用XPath定位iframe
driver.switch_to_frame(driver.find_element_by_xpath("//td[@id='frame_td']/iframe")
)
#操作iframe页面
driver.find_element_by_id('kw').send_keys(u'查询')
#回到默认页面
driver.switch_to_default_content()
driver.find_element_by_id('user').send_keys('111')
selenium(四)--iframe
最新推荐文章于 2024-06-17 22:01:19 发布