luckyframework / lucky_flow

Automated browser tests for web applications. Similar to Ruby's Capybara.
https://luckyframework.github.io/lucky_flow/
MIT License
51 stars 8 forks source link

Remove Selenium dependency from LuckyFlow::Element #136

Closed matthewmcgarvey closed 2 years ago

matthewmcgarvey commented 2 years ago

Allows for each driver implementation to have its own element so that custom code can be isolated.

Unfortunate downside, elements are no longer lazily loaded so page.el("h1").should be_on_page is no longer possible. It will raise an error on page.el("h1") if there is no h1 tags to find.

The original intent of having elements be lazily loaded was so that we could have having complicated spec matchers. Ruby's Capybara library has more than a handful of custom expectations to work around this

have_selector '.blank-state'
have_selector 'h1#hola', text: 'Welcome'
have_button 'Save'
have_checked_field '#field'
have_unchecked_field
have_css '.class'
have_field '#field'
have_table '#table'
have_xpath '//div'

We didn't need all these because the lazy matching allowed us to be able to handle the case where the element was missing.

el = page.el("@my-flow-id")
el.should be_on_page
el.text.should eq("foo")

The upside of this change is that when we add in an in-memory driver, it can produce elements in its own way.

This would be a breaking change.

page.el("h1").should be_on_page # no longer works
page.should have_displayed_element("h1") # works