我正在尝试创建一个测试用例,在 tinymce 中选择一些文本,然后将样式从段落更改为标题。我有一些几乎可以工作的代码,但它必须运行两次才能正常工作。以下是逐步执行工具栏菜单第一行上每个按钮的代码的摘录。我想知道为什么我需要运行它两次。我可以在第一次悬停并单击期间看到下拉菜单下拉菜单,但除非我第二次运行代码,否则格式不会更改。
b.frame(id:"content_ifr").p.select_text "to try"
b.table(:id => 'content_formatselect').hover
b.table(:id => 'content_formatselect').click
b.span(:title => 'Heading 1').hover
b.span(:title => 'Heading 1').click
#second time
b.table(:id => 'content_formatselect').hover
b.table(:id => 'content_formatselect').click
b.span(:title => 'Heading 1').hover
b.span(:title => 'Heading 1').click
测试来自http://www.tinymce.com/tryit/full.php页面。这里有更多的代码,在这一点上它是相当基本的,但它确实有效。我确实将跨度更改为 a 标签,但这并不影响结果。
require 'watir-webdriver'
require 'watir-webdriver/extensions/select_text'
#require 'test/unit'
b = Watir::Browser.new :firefox
b.goto "http://www.tinymce.com/tryit/full.php"
b.div(:id => 'main').wait_until_present
bodyy = b.textarea(:name => 'content').value
b.textarea(:value => /Feel free/).exists?
b.frame(id:"content_ifr").p.select_text "Feel free"
b.a(:title => 'Bold (Ctrl+B)').hover
b.a(:title => 'Bold (Ctrl+B)').click
b.a(:title => 'Italic (Ctrl+I)').hover
b.a(:title => 'Italic (Ctrl+I)').click
b.a(:title => 'Underline (Ctrl+U)').hover
b.a(:title => 'Underline (Ctrl+U)').click
b.a(:title => 'Strikethrough').hover
b.a(:title => 'Strikethrough').click
b.a(:title => 'Align Left').hover
b.a(:title => 'Align Left').click
b.a(:title => 'Align Center').hover
b.a(:title => 'Align Center').click
b.a(:title => 'Align Right').hover
b.a(:title => 'Align Right').click
b.a(:title => 'Align Full').hover
b.a(:title => 'Align Full').click
b.table(:id => 'content_styleselect').hover
b.table(:id => 'content_styleselect').click
b.a(:text => 'example2').hover
b.a(:text => 'example2').click
b.table(:id => 'content_styleselect').hover
b.table(:id => 'content_styleselect').click
b.a(:text => 'example1').hover
b.a(:text => 'example1').click
b.table(:id => 'content_styleselect').hover
b.table(:id => 'content_styleselect').click
b.a(:text => 'tablerow1').hover
b.a(:text => 'tablerow1').click