tinymce でテキストを選択し、スタイルを段落から見出しに変更するテスト ケースを作成しようとしています。ほとんど機能するコードがいくつかありますが、機能させるには2回実行する必要があります。以下は、ツールバー メニューの最初の行にある各ボタンをステップ実行するコードからの抜粋です。なぜ2回実行する必要があるのか 疑問に思っています。最初のホバー アンド クリック時にドロップダウン メニューのドロップダウンが表示されますが、コードを 2 回目に実行しない限り、形式は変更されません。
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