【问题标题】:cannot send contents to /html/body/p under iframe for rich text editior无法在富文本编辑器的 iframe 下将内容发送到 /html/body/p
【发布时间】:2015-09-29 06:45:18
【问题描述】:

在这个编辑器中,当你输入内容时,所有内容都转到标签<p>,但系统无法识别/html/body/p,所以我使用/html/body或切换到活动元素,两者都不起作用。

            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 = '<br>'")
            webElement = driver.find_element_by_xpath("/html/body")
            webElement.send_keys(developreqTestData["inputOne"][inputNotes])
            time.sleep(1)
            driver.switch_to_default_content()
            time.sleep(0.5)

【问题讨论】:

  • 我使用 PhantomJS 1.9.2

标签: python selenium iframe selenium-webdriver automation


【解决方案1】:

driver.execute_script("document.body.innerHTML = '你的内容'")

这行得通

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多