I am trying to create a test case that selects some text in tinymce and than changes the style from paragraph to a heading. I have some code that almost works but it has to be run twice for it function. The following is an excerpt from the code that steps through each button on the first row of the toolbar menu. I am wondering why I need to run it twice. I can see the dropdown menu dropdown during the first hover and click but the format is not changed unless I run the code the second time.
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
The test is from the http://www.tinymce.com/tryit/full.php page. Here is more of the code it is fairly basic at this point but it does work. I did change the span to an a tag but that did not affect the outcome.
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