如何使用robot框架和Selenium2库选择TinyMCE字段的文本

如何使用robot框架和Selenium2库选择TinyMCE字段的文本,tinymce,plone,selenium-webdriver,robotframework,Tinymce,Plone,Selenium Webdriver,Robotframework,我正在尝试选择一个带有Selenium2库关键字的TinyMCE字段的文本(在Plone中) 我尝试使用鼠标事件(鼠标下/上/下)、Javascript和“双击元素”来选择文本,但到目前为止没有任何效果。如果我设置了调试器并手动选择文本,下面的代码可以工作: Go to ${PLONE_URL}/++add++Document Input Text name=form.widgets.IDublinCore.title My Document Select frame id=

我正在尝试选择一个带有Selenium2库关键字的TinyMCE字段的文本(在Plone中)

我尝试使用鼠标事件(鼠标下/上/下)、Javascript和“双击元素”来选择文本,但到目前为止没有任何效果。如果我设置了调试器并手动选择文本,下面的代码可以工作:

  Go to  ${PLONE_URL}/++add++Document
  Input Text  name=form.widgets.IDublinCore.title  My Document
  Select frame  id=form.widgets.text_ifr
  Input text  id=content  Lorem Ipsum
  # Attempt with Javascript
  Execute Javascript  document.getElementById("content").select()
  # Attempt with Double Click
  Double Click Element  xpath=//body[@id='content']/p[1]
  Double Click Element  id=content
  # Attempt with Mouse Events
  Mouse Down  xpath=//body[@id='content']/p[contains(text(),'L')]
  Mouse Over  xpath=//body[@id='content']/p[contains(text(),'orem')]
  Mouse Up  xpath=//body[@id='content']/p[contains(text(),'Ipsum')]
  # When I set a debug statement here and select the text manually the test passes
  Unselect Frame
  Click Link  id=form.widgets.text_link
  Wait until page contains element  id=mce_31_ifr
  Select frame  id=mce_31_ifr
  Click Link  News
  ...

如果有人能推荐哪种方法最有希望,这已经很有帮助了。

这只是一个重复。对于内容可编辑的元素,我认为JavaScript是一个不错的选择。下面的代码选择TinyMCE小部件的内容可编辑部分的整个主体

Open Browser    http://www.tinymce.com/    gc
Select Frame    id=editMe_ifr
Input Text    id=tinymce    Lorem Ipsum
Execute Javascript    function selectElementContents(el) {var range = document.createRange(); range.selectNodeContents(el); var sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(range);} var el = document.getElementById("tinymce"); selectElementContents(el);

谢谢你的回答。TinyMCE字段中的文本现在处于选中状态。不过,TinyMCE似乎没有检测到这一点(至少在测试中没有)。工具栏中的“链接”按钮仍处于禁用状态(应在选择文本后立即可用)。嗨,Tisto,你找到了怎么做的方法吗?我可以在firefox中使用它,但在phantomjs中不起作用。