frame嵌套页面元素定位
from selenium import webdriver
from time import sleep
driver=webdriver.Firefox()
#设置网页文件路径,r代表路径转义
file_path=r"D:\Python_script\Webdriver\Frame.html"
#路径转义另一种写法
# file_path='E:\\Python_script\\Webdriver\\Frame.html'
driver.get(file_path)
#切换到frame页面内
driver.switch_to.frame("search")
#定位到搜索框按钮输入关键词
driver.find_element_by_css_selector("#query0").send_keys("python")
sleep(2)
driver.find_element_by_css_selector("#stb").click()
driver.quit()
标签:frame,driver,嵌套,file,path,页面
From: https://www.cnblogs.com/hahaniuer/p/16874280.html