新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
selenium學(xué)習(xí):多表單的切換
文件:frame.html

從策劃到設(shè)計(jì)制作,每一步都追求做到細(xì)膩,制作可持續(xù)發(fā)展的企業(yè)網(wǎng)站。為客戶提供網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、網(wǎng)站策劃、網(wǎng)頁設(shè)計(jì)、空間域名、虛擬主機(jī)、網(wǎng)絡(luò)營銷、VI設(shè)計(jì)、 網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,以客戶的口碑塑造優(yōu)易品牌,攜手廣大客戶,共同發(fā)展進(jìn)步。
frame
文件:test11.py
from selenium import webdriver
import os,time
driver = webdriver.Chrome()
file_path='file:///'+os.path.abspath('frame.html')
driver.get(file_path)
#由于使用的是iframe,內(nèi)嵌,因此需切換到iframe(id="if")
from selenium import webdriver
import os,time
driver = webdriver.Chrome()
file_path='file:///'+os.path.abspath('frame.html')
driver.get(file_path)
#由于使用的是iframe,內(nèi)嵌,因此需切換到iframe(id="if")
driver.switch_to.frame("if")
time.sleep(3)
driver.find_element_by_id("kw").send_keys("selenium")
driver.find_element_by_id("su").click()
time.sleep(3)
driver.quit()swith_to_frame()默認(rèn)直接獲取表單的id或name屬性,若iframe無可用的id活name,則可以通過下述方法進(jìn)行定位:
xf=driver.find_element_by_path('//*[@class="if"]')
driver.switch_to.frame(xf)
driver.switch_to_.parent_frame() 網(wǎng)站欄目:selenium學(xué)習(xí):多表單的切換
路徑分享:http://www.dlmjj.cn/article/gihosc.html


咨詢
建站咨詢
