2014-02-06 42 views
1

我在使用tinymce版本3.5.8時遇到了麻煩。用硒自動化tinymce

def self.content(text) 
    # to write on a WYSIWYG editor write on the iframe 
    $driver.switch_to.frame('WikiRevision_content_ifr') 
    $driver.find_element(:id, 'tinymce').send_keys text 
    $driver.switch_to.default_content 
    self 
end 

我的所見即所得編輯器上沒有內容出現。沒有錯誤發生。
試圖在TinyMCE的寫紅寶石2.0和硒的webdriver 2.39

回答

1

Here是你可能會發現有用的文章 - 「Test WYSIWYG editors using Selenium WebDriver

對於您的問題,一些事情你可以試試。 (假設你的幀切換做得正確,顯示你的HTML,如果你需要幫助。)

  • 發送鍵體(不知道你id=tinymce是什麼不知道HTML)
$driver.switch_to.frame('WikiRevision_content_ifr') 
$driver.find_element(:css, 'body').send_keys text 
  • 設置的innerHTML
$driver.switch_to.frame('WikiRevision_content_ifr') 
$driver.execute_script("arguments[0].innerHTML = 'arguments[1]'", $driver.find_element(:css => 'body'), text) 
  • TinyMCE中使用的原生JS
$driver.execute_script("tinyMCE.activeEditor.setContent('arguments[0]')", text) 
+0

@Zach:你對此有何意見?它對你有用嗎? –

+0

原生JS方法爲我工作。 – Kong