Open PanoramicPanda opened 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.
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
class WindowElement < CoreElement
def self.element_type; :window end
def value
watir_element.title
end
end
Something like that
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.
Technically speaking, window can take a selector.
window(title: /Google/)
this means we'd have to add title as a valid selector though.
but add_id_element(:window, /Google/, title: 'Google')
would feel a bit redundant.
Where as add_id_element(:window, /Google/)
doesn't.
Caught me on my own argument with that one... that's a great point.
would we be okay defaulting the selector to {}?
🤔 Perhaps? @greenarrowdb I'd like your input on this issue at some point
@greenarrowdb
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 utilizeparent.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.