2013-02-26 28 views
1

我想在Tinymce Editor中使用Cucumber和selenium驅動程序進行功能自動化測試的頁面中填寫文本。我能夠打開圖像對話框,但無法填寫它內部的文本字段。我知道TinyMce有嵌入的iframe標籤,其中包含其他html。 我用下面的步驟,但沒有奏效。fill_in in tinyMce

When /^I fill in the xpath "([^"]*)" with "([^"]*)"$/ do |xpath, value| 
    find(:xpath, xpath).set 'value' 
end 

When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value| 
    fill_in(field, :with => value) 
end 

我得到一個錯誤Unable to find xpath PFA圖像爲refrenece。 enter image description here

回答

0

這個工作對我....

When ^I enter (.+) in textbox of tinymce iframe having id as (.+)$ do |any_details,tiny_id| 
    within_frame("#{tiny_id}") do 
    fill_in("image_name", :with =>any_details) 
    end 
end 

此外,在編輯器中選擇整個文字自動化,使用此:C

When ^I select the entire textarea content in the editor$ do 
    evaluate_script("tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);") 
end 
0

試試這個:

When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value| 
    sleep 0.5 until page.evaluate_script("tinyMCE.get('#{field}') !== null") 
    js = "tinyMCE.get('#{field}').setContent('#{val}')" 
    page.execute_script(js) 
end 

僅供參考,請查看gist