OzFramework / oz

Oz is a behavioral web-ui testing framework developed to reduce test maintenance by using a predictive model rather than a scriptive model when writing tests.
Apache License 2.0
23 stars 7 forks source link

[Feature Evaluation] Bulk element definitions #140

Open Castone22 opened 5 years ago

Castone22 commented 5 years ago

I'm thinking on this a little bit but.. something like the following pattern might be somewhat more user friendly when defining a lot of the same element type

add_links({
  link_one: {href: '/one'},
  link_two: {href: '/two'},
  link_three: {href: '/three'}
})

Implementation wouldn't be too hard and it reduces repetition as well as reduces cyclic complexity of some of the methods we write in our base pages, also would let particularly complex pages be extracted into a yaml file in some situations a lot more easily.

def add_link_elements(element_hash)
  element_hash.each { |name, selectors| add_link(name, selectors) }
end
greenarrowdb commented 5 years ago

This is a very interesting concept so far. I'd like to discuss this further. What do you mean by "let particularly complex pages be extracted into a yaml file in some situations a lot more easily"

Castone22 commented 5 years ago

A Pattern like this

#~! pages/yaml_page.rb
class YamlPage < BasePage
  include Oz::YamlLoadedPage
end
#~! yaml_page_elements.rb
:links:
  :submit:
    :id: 'submit-button'

:text_fields:
  :first_name:
    :id: 'first_name'
  :last_name:
    :id: 'last_name'

etc etc

greenarrowdb commented 5 years ago

Why? I don't see an advantage to this level of abstraction. You loose all ability to be dynamic this way and I don't see a good reason to do it.

Castone22 commented 5 years ago

Eh, just an idea. The core thing is really the replication reduction we would get from being able to bulk add

greenarrowdb commented 5 years ago

There is definitely something to that statement for sure. I think there are a couple ways we could potentially go about it (they are pretty much all variations similar to this). We should chat about this one over discord soon :)