【问题标题】:Tinymce select textTinymce 选择文本
【发布时间】:2012-12-08 04:59:05
【问题描述】:

我是 ruby​​ 和 watir-webdriver 的新手。我正在尝试从http://www.tinymce.com/tryit/full.php 网站学习如何测试tinymce。我可以单击“粗体”等按钮,但我不知道是否有办法在文本区域中选择/突出显示文本来测试“粗体”按钮。我可以在 textarea 中找到文本“随意”,但我不确定如何选择文本。我注意到其他帖子提到 Tinymce 在框架中,但它似乎不在当前页面的框架中。

这是该部分的样子(编辑后的表格)

<textarea id="content" style="width: 100%; height: 550px; display: none;" name="content" cols="20" rows="20" aria-hidden="true">
 <p>Feel free to try out the different features ...</p>
</textarea>


require 'watir-webdriver'

b = Watir::Browser.new :firefox
b.goto "http://www.tinymce.com/tryit/full.php"

b.div(:id => 'main').wait_until_present
b.textarea(:value => /Feel free/).exists? #this evaluates to "true"

Where I need to select the text

b.a(:title => 'Bold (Ctrl+B)').hover
b.a(:title => 'Bold (Ctrl+B)').click

【问题讨论】:

    标签: tinymce watir-webdriver


    【解决方案1】:

    是的,编辑器在一个框架中。这会从Welcome to the TinyMCE editor demo! 中选择to

    require "watir-webdriver"
    
    browser = Watir::Browser.new :firefox
    browser.goto "http://www.tinymce.com/tryit/full.php"
    
    require "watir-webdriver/extensions/select_text"
    browser.frame(id:"content_ifr").h1.select_text "to"
    

    【讨论】:

    • 感谢 Zeljiko 的快速回答。
    • 我一定是萤火虫设置错误。它现在向我显示页面上的 iframe。我也不知道 select_text 是一个需要加载的扩展。代码现在将我选择的文本加粗。我想我需要找到一些关于这个主题的好教程。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-26
    • 1970-01-01
    相关资源
    最近更新 更多