在使用
iframe进行测试并尝试在
iframe中插入数据时,这对我适用于
Python(v。2.7),
webdriver和
Selenium:
self.driver = webdriver.Firefox()## Give time for iframe to load ##time.sleep(3)## You have to switch to the iframe like so: ##driver.switch_to.frame(driver.find_element_by_tag_name("iframe"))## Insert text via xpath ##elem = driver.find_element_by_xpath("/html/body/p")elem.send_keys("Lorem Ipsum")## Switch back to the "default content" (that is, out of the iframes) ##driver.switch_to.default_content()


