<div dir="ltr">On Fri, Oct 3, 2014 at 1:45 PM, Chris McMahon <span dir="ltr"><<a href="mailto:cmcmahon@wikimedia.org" target="_blank">cmcmahon@wikimedia.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div> I made a wiki page: <a href="https://www.mediawiki.org/wiki/Quality_Assurance/Browser_testing/Guidelines_and_good_practices" target="_blank">https://www.mediawiki.org/wiki/Quality_Assurance/Browser_testing/Guidelines_and_good_practices</a></div></div></blockquote><div><br></div><div>Great, though I think it should be merged with Writing tests.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Comments, criticism, and updates are welcome. </div></div></blockquote><div><br></div><div>The page says<br>- - - -<br>Sometimes when AJAX is involved this means that you have to do something that seems like duplication but it is not:
<pre>Then(/^the top post is an open discussion$/) do
  on(FlowPage) do |page|
    page.flow_first_topic_moderation_msg_element.when_not_present
    expect(page.flow_first_topic_moderation_element).not_to be_visible
  end
end
</pre>
<p>The following is not correct, because <span style="font-family:courier new,monospace">when_not_present</span> is not an assertion:</p>
<pre>Then(/^the top post is an open discussion$/) do
  on(FlowPage).flow_first_topic_moderation_msg_element.when_not_present #THIS IS NOT AN ASSERTION
end
</pre>- - - -<br><br>But the first (recommended) test never fails on the expect(), it times out waiting for the element not to be present. And two lines is more verbose and prone to error (I deliberately mismatched the element names above, did you catch it?).<br><p>Is there a way to say "expect the item to <i>eventually</i> (default 5 seconds)  not be visible?" E.g.:<br></p><pre> expect(page.some_dynamic_element).eventually_not_to be_visible<br><br><span style="color:rgb(255,0,0)">expected visible? to eventually return false, still true after 5 seconds (RSpec::Expectations::ExpectationNotMetError)</span><br></pre></div></div>That would make the intent of tests much clearer, without repetition.<br><br></div><div class="gmail_extra">The other problem with expect is it doesn't tell you what element failed. <span style="font-family:courier new,monospace">when_not_present</span>'s error message below is easier to debug:<br></div><div class="gmail_extra"><br><font size="1"><span style="font-family:courier new,monospace"><span style="color:rgb(255,0,0)">    timed out after 5 seconds, waiting for {:title=>"Edit header", :tag_name=>"a"} to disappear (Watir::Wait::TimeoutError)</span></span></font><br><br></div><div class="gmail_extra">I think the fix for that is to expand expect() to be aware of what it's testing so it can print specific failures.  Not just .to and .not_to , but .to_eventually_be_visible , .to_match_text, etc.  At that point I would prefer assertEventuallyVisible(), assertMatches(), etc. because you can tell what kind of test it is at the start of the line.<br><br><br></div><div class="gmail_extra">Anyway, progress, thanks!<br></div><div class="gmail_extra">--<br><div dir="ltr">=S Page  Features engineer<br></div>
</div></div>