Alp*_*nar 11 selenium tinymce ruby-on-rails cucumber capybara
我使用水豚测试tinymce形式有困难.我正在使用tinymce-rails并且在我的表单中有7个编辑器.我也使用asciimath插件与tinymce.
一切正常,但我无法编写测试来填写tinymce编辑器.
以下是我的步骤定义代码的外观,与此处描述的内容非常相似:
within_frame("content_ifr") do
editor = page.find_by_id('tinymce')
editor.native.send_keys 'test'
end
Run Code Online (Sandbox Code Playgroud)
问题是当我运行以下内容时:
editor.native.clear # works, clear the editor area, I'm testing this with pry
editor.native.send_keys :tab # works, moves focus to next input
editor.native.send_keys 'test' # returns "", nothing happens, nothing in editor
Run Code Online (Sandbox Code Playgroud)
所以clear
,send_keys :tab
按预期工作.但我不能发送任何字符串.send_keys
函数总是返回空字符串,当我使用pry进行测试时没有任何反应.
这里出了什么问题?以及如何调试/调查问题?
谢谢.
我知道这是一个古老的问题,但我在试图解决这个问题时才发现它.
虽然最初的问题说他在同一页面上有7个tinymce,但我认为我的解决方案也可能适用于他,但我知道如果有一个像我的情况那样,它会起作用.
在我的请求规范中我使用了这个:
page.execute_script('$(tinymce.editors [0] .setContent("我的内容在这里"))')
page.execute_script告诉它运行jQuery函数.然后它找到第一个tincymce编辑器并设置内容.
对我来说就像一个魅力.我想如果有一个以上的可以通过它的位置来调用它.