[QA] checking that an element does not appear

Chris McMahon cmcmahon at wikimedia.org
Mon Sep 30 15:06:05 UTC 2013


I see a couple of issues here.  The line you have (and other lines in that
steps file) is:

on(MainPage).project_tile_element.div(class: 'tux-statsbar').should_not
be_visible

First of all, please define the elements in the page in a PageObject in the
directory features/support/pages/main_page.rb, for example
------
class MainPage
  include PageObject

  include URL
  page_url URL.url('Special:Mainpage')

  div(:project_tile, class: 'tux-statsbar')
end
-----

You should never define a page element in a test step.  It makes the test
difficult to debug and nearly impossible to maintain over time.  Page
elements should only ever be defined within a PageObject.

Once you've done that, the line in the steps file becomes:

on(MainPage).project_tile_element.should_not be_visible

which is valid.

If that check does not pass, you may have to wait for project_tile to
disappear:

on(MainPage) do |page|
    page.wait_until(10) do
      page.text.include? 'Something '
         #OR ANY CONDITION
    end
    page.project_tile_element.should_not be_visible
  end









On Fri, Sep 27, 2013 at 6:55 PM, Amir E. Aharoni <
amir.aharoni at mail.huji.ac.il> wrote:

> Hi,
>
> I am trying to check that an element does not appear:
>
> https://gerrit.wikimedia.org/r/#/c/86348/1/tests/browser/features/step_definitions/signed_in_source_language_steps.rb
>
> I tried to do <element>.should_not be_visible, but apparently that is
> invalid.
>
> What is the most robust way to do it?
>
> Thanks!
>
> --
> Amir Elisha Aharoni · אָמִיר אֱלִישָׁע אַהֲרוֹנִי
> http://aharoni.wordpress.com
> ‪“We're living in pieces,
> I want to live in peace.” – T. Moore‬
>
> _______________________________________________
> QA mailing list
> QA at lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/qa
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wikimedia.org/pipermail/qa/attachments/20130930/8a8522f0/attachment.html>


More information about the QA mailing list