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

Title Element cannot be used for ID or Wait Element #146

Open PanoramicPanda opened 5 years ago

PanoramicPanda commented 5 years ago

Due to the both way core_element determines the watir_element and the required arguments of an ID Element, the Title of the HTML page cannot be used.

Watir's call of browser.title just directly returns the title string, with no arguments required. Since ID Elements utilize parent.send(@element_type, @locator_hash) and the title needs no locator, we cannot use it.

Unsure if we'd ever really want to use it as a Wait Element, but can't be used there either due to the same effect.

PanoramicPanda commented 5 years ago

Making this possible would also require a re-work in how the ID element would determine presence, as the title just returns a string back instead of an element.

Castone22 commented 5 years ago

If i'm remembering correctly, #.title is actually an attribute on the window (in chrome's case, this is a tab.) And <Watir::Browser#instantiated>.title will just return the title of the currently selected window. You can actually test this with irb

irb(main):044:0> @browser.windows.map{|it| it.title}
=> ["Hello World - Google Search", "Stack Overflow - Where Developers Learn, Share, & Build Careers"]

From an implementation standpoint, we could probably create a WindowElement in oz that overrides value to call watir_element.title where element_type: window

Castone22 commented 5 years ago
class WindowElement < CoreElement
  def self.element_type; :window end
  def value
    watir_element.title
  end
end

Something like that

PanoramicPanda commented 5 years ago

While this does definitely help (and I had the same thing worked out in my head), the ID Element would still need changed a bit to handle it, as it takes a element type, value, and locator hash. We might be able to just have it be bogus and the element ultimately ignore it, but that feels... dirty.

Castone22 commented 5 years ago

Technically speaking, window can take a selector.

window(title: /Google/)

Castone22 commented 5 years ago

this means we'd have to add title as a valid selector though.

PanoramicPanda commented 5 years ago

but add_id_element(:window, /Google/, title: 'Google') would feel a bit redundant.

Where as add_id_element(:window, /Google/) doesn't.

Castone22 commented 5 years ago

Caught me on my own argument with that one... that's a great point.

Castone22 commented 5 years ago

would we be okay defaulting the selector to {}?

PanoramicPanda commented 5 years ago

🤔 Perhaps? @greenarrowdb I'd like your input on this issue at some point

Castone22 commented 5 years ago

@greenarrowdb