[QA] Page elements

Željko Filipin zfilipin at wikimedia.org
Mon Jan 27 12:50:42 UTC 2014


Including QA mailing list in the discussion, with Tobi's permission.

To give you some context, here is the problem:

There are several similar elements on the page:

...
module StatementPage
  include PageObject
...
  div(:statement1_name, css: ".wb-claimlistview:nth-child(1) div.wb-claim-name")
  div(:statement2_name, css: ".wb-claimlistview:nth-child(2) div.wb-claim-name")
...
end

Is it possible to create a generic element? Something like this:

...
module StatementPage
  include PageObject
...
  div(:statement_name, css: ".wb-claimlistview:nth-child(#{index})
div.wb-claim-name")
...
end

This is what we ended up doing, falling back to Watir API, since we could
not figure how to do it with page-object API:

...
module StatementPage
  include PageObject
...
  def statement_name_element(index)
    @browser.element(css: ".wb-claimlistview:nth-child(#{index})
div.wb-claim-name")
  end
...
end


Feel free to comment here, in Gerrit[1] or Github[2] or Twitter[3].

Željko
--
1: https://gerrit.wikimedia.org/r/#/c/109103
2: https://github.com/cheezy/page-object/issues/203
3: https://twitter.com/zeljkofilipin/status/427782047671648256

On Thu, Jan 23, 2014 at 5:44 PM, Tobi Gritschacher <
tobias.gritschacher at wikimedia.de> wrote:

> Hey,
>
> I tried something you showed me some time ago and explained in this email.
> But it seems I'm doing something wrong. Do you have any Idea? See my
> comment in https://gerrit.wikimedia.org/r/#/c/109103/
>
> thx!
>
> cheers, tobi
>
>
> On Wed, Sep 18, 2013 at 7:17 PM, Željko Filipin <zfilipin at wikimedia.org>wrote:
>
>> This two methods do the same thing, but the first one has a few added
>> features and it is shorter.
>>
>>   table(:enwiki, class: "enwiki")
>>
>>   def enwiki_element
>>     @browser.table(class: "enwiki")
>>   end
>>
>>
>>
>> This
>>
>>   table(:enwiki, class: "enwiki")
>>   div(:enwiki, class: "enwiki")
>>   ...
>>
>> could be simplified like this
>>
>>   def language_element(type)
>>     # type = :div
>>     send(type, :enwiki, class: "enwiki")
>>   end
>>
>>
>>
>> This
>>
>>   table(:enwiki, class: "enwiki")
>>   table(:dewiki, class: "dewiki")
>>   ...
>>
>> Could be simplified like this
>>
>>   def language_element(language)
>>     table("#{language}wiki".to_sym, class: "#{language}wiki")
>>   end
>>
>> Let me know if you have any questions! :)
>>
>> Željko
>>
>>
>
>
> --
> Tobi Gritschacher
> Software Developer - Wikidata - http://www.wikidata.org
>
> Imagine a world, in which every single human being can freely
> share in the sum of all knowledge. That‘s our commitment.
>
> Wikimedia Deutschland e.V. | Tempelhofer Ufer 23-24 | 10963 Berlin
> Phone +49 (0)30 219 158 260
>
> http://wikimedia.de <http://www.wikimedia.de/>
>
> Wikimedia Deutschland - Gesellschaft zur Förderung Freien Wissens e.V.
> Eingetragen im Vereinsregister des Amtsgerichts Berlin-Charlottenburg unter
> der Nummer 23855 B. Als gemeinnützig anerkannt durch das Finanzamt für
> Körperschaften I Berlin, Steuernummer 27/681/51985.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wikimedia.org/pipermail/qa/attachments/20140127/a4eb87e8/attachment.html>


More information about the QA mailing list