2012-06-18 54 views
0

使用Watir Webdriver我能夠檢測到所見即所得ckeditor存在,但是任何嘗試send_keys都會輸出空白字符串?使用Watir Webdriver和WYSIWYG

我能夠沒有問題,運行上面的CKEditor的測試:

require "watir-webdriver" 
b = Watir::Browser.new :firefox 
b.goto "http://ckeditor.com/demo" 
b.frame(:title => 'Rich text editor, editor1, press ALT 0 for help.').send_keys "hello world" 

我然而,其運行我自己的測試這個代碼的問題:

b.frame(:title, "Rich text editor, currentItem.contentText, press ALT 0 for help.").exists? 
=> true 

b.frame(:title, "Rich text editor, currentItem.contentText, press ALT 0 for help.").send_keys 'text' 
=>"" 

沒有呈現到所見即所得。 網頁上的其他框架允許我編輯文本字段。有什麼想法嗎?

+0

我不想使用execute_script方法,因爲它會使我的測試無效。 – alp2012

+0

爲什麼使用execute_script方法會使測試失效?除非實際開發自己的所見即所得編輯器,否則您不是在測試編輯器,而是可以用它來嚮應用程序添加內容,這是通過execute_script方法實現的? –

回答

2

一般來說,將密鑰發送到整個幀是一個壞主意。

根據我對FCKEditor的經驗,如果我發現特定元素可以響應.send_keys方法,我只能使用它。

這裏的東西,對我的作品(我猜測,我的第一幀元素的引用將是等同於你正在使用的「稱號」打框架元素標籤)爲例:

@browser.frame(:id, "body___Frame").td(:id, "xEditingArea").frame(:index=>0).send_keys "your text here"