在使用Selenium WebDriver的Python中获取iframe的内容是否可能?

2024-09-30 16:36:52 发布

您现在位置:Python中文网/ 问答频道 /正文

在web测试中,我计划获取iframe(/htme/body/p)的内容,有可能吗?在

我使用这个方法来设置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()

Tags: to方法web内容timedriverbodysleep