【发布时间】: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
【问题讨论】: