问题描述:

In web testing, I plan to get contents of iframe(/htme/body/p), is is possible?

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()

网友答案:

To follow the same logic, you can get the document.body.innerHTML back:

source = driver.execute_script("return document.body.innerHTML;")
print(source)
相关阅读:
Top