是否可以在selenium webdriver python中获取iframe的内容? [英] Is it possible to get contents of iframe in selenium webdriver python?
本文介绍了是否可以在selenium webdriver python中获取iframe的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在网络测试中,我计划获取iframe的内容(/ htme / body / p),是否可能?
In web testing, I plan to get contents of iframe(/htme/body/p), is is possible?
我使用此方法设置内容iframe:
I use this method to set contents of iframe:
driver.switch_to_frame(driver.find_element_by_xpath("//iframe[contains(@title,'ALT')]"))
driver.switch_to_active_element()
time.sleep(1)
driver.execute_script(("document.body.innerHTML = '%s'" % recurWorkflowTestData["inputEditor"][inputNotes]))
time.sleep(1)
driver.switch_to_default_content()
推荐答案
为了遵循相同的逻辑,你可以得到 document.body.innerHTML
返回:
To follow the same logic, you can get the document.body.innerHTML
back:
source = driver.execute_script("return document.body.innerHTML;")
print(source)
这篇关于是否可以在selenium webdriver python中获取iframe的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文