0
我試圖自動化頁面上的控件,在哪裏有一個iframe和一個可以用AutoIT控制的元素。我需要點擊iframe中的掃描按鈕。我用driver.switch_to.frame("frmDemo")
來切換幀,但它似乎不工作。請任何想法嗎?Selenium,Autoit和iframe
下面是代碼:
import win32com.client
import time
from selenium import webdriver
autoit = win32com.client.Dispatch("AutoItX3.Control")
# create a new Firefox session
driver = webdriver.Firefox()
driver.implicitly_wait(30)
driver.get("http://example.com")
time.sleep(2)
driver.switch_to.frame("frmDemo")
scanButton = driver.find_element_by_css_selector('body.input[type="button"]')
scanButton.click()
感謝嘗試。去除'身體'使它工作! –