如何使用 Watir-WebDriver 将文本发送到 CKEditor WYSIWYG 编辑器框 [英] How to send text to a CKEditor WYSIWYG editor box using Watir-WebDriver

查看:28
本文介绍了如何使用 Watir-WebDriver 将文本发送到 CKEditor WYSIWYG 编辑器框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 watir-webdriver 脚本,它使用下面的代码设置一个 CKEditor 框,但是当我专注于屏幕时,这只适用于 Mac OSX 上的 Firefox.例如,如果我将注意力移开并让此脚本在后台运行,则不会输入文本(但不会引发异常或错误).

I have a watir-webdriver script that sets a CKEditor box using the code below, but this only works with Firefox on Mac OSX when I focus on the screen. For example, if I focus away and let this script run in the background, the text is not entered (but no exception or error is raised).

有人知道如何始终确保设置了吗?

Anyone know how to always ensure it is set?

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"

(谷歌浏览器在 Mac OSX 上运行正常,但我也想在 Firefox 上运行我的测试)

(Google Chrome works ok on Mac OSX, but I would like to run my tests against Firefox too)

推荐答案

多亏了 Jari 的指针,我最终执行了 javascript 来可靠地更新字段:

Thanks to Jari's pointer, I ended up executing javascript to update the field reliably:

b.execute_script "CKEDITOR.instances.editor1.setData( 'hello' );"

这篇关于如何使用 Watir-WebDriver 将文本发送到 CKEditor WYSIWYG 编辑器框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆