Skip to content

Capybara 3.0#204

Merged
tlconnor merged 8 commits intomasterfrom
capybara3
May 4, 2018
Merged

Capybara 3.0#204
tlconnor merged 8 commits intomasterfrom
capybara3

Conversation

@tlconnor
Copy link
Copy Markdown

@tlconnor tlconnor commented May 4, 2018

This pull request adds support for Capybara 3.0.

In addition to this the following changes are made:

  • Added Document#reload to allow a reliable method of reloading the current page without needing to create a new page object.
  • Fixed a deprecation warning when using XPath selectors
  • Fixed cases where StaleElementReferenceError can occur on page reload
  • Removed support for ruby < 2.2.5
  • Changed tests to run headless with Selenium 3.11
  • Removed appraisals for Rails < 4.2

Comment thread test/unit/document_test.rb Outdated

kitty_page = kitty_class.new
capybara_stub.session.driver.expects(:execute_script) do |script|
puts script
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this puts?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I was supposed to put assertions here about the contents of the script but missed it because the test passed! Now fixed.

Comment thread .travis.yml

# Integration tests
include:
- env: RAILS_VERSION=4.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is good that we are leaving 4.2 not only for ourselves but because this is open source.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean here. Are you saying you are glad I didn't get rid of 4.2, or are you suggesting we should keep 4.0?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The former.

Comment thread ae_page_objects.gemspec Outdated

s.required_ruby_version = '>= 1.9.3'
s.required_ruby_version = '>= 2.2.5'
s.authors = ["Donnie Tognazzini"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this line?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, changed to "AppFolio Engineering"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


def size
node.all(:xpath, item_xpath, options).size
node.all(:xpath, item_xpath, options.merge(wait: false)).size
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine this may cause some failures that will need to be updated to use the assert_eventually assertions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Capybara 3.0 Element#all was changed to wait by default for at least one element.

The line here just maintains existing behavior by making it not wait. The Collection#size method needs to return the current size, whether it is 0 or above.

node.first(*eval_locator(locator)) != nil
else
locator = eval_locator(loaded_locator)
if locator.empty?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this change. We count it as loaded if there is no locator?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is maintaining existing behavior, I've just swapped the if/else so that rubocop doesn't complain about assigning a variable within an if statement.

Comment thread lib/ae_page_objects/element.rb Outdated
@locator == default_locator
end

def reload_descendents
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name reload_descendents and the comment seem to conflict with eachother. "descendent" indicates down to me, but we're going up? Maybe reload_predecessors, reload_parents, reload_ancestors?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I've renamed it to reload_ancestors

end

implicit_element.__send__(name, *args, &block)
rescue Selenium::WebDriver::Error::StaleElementReferenceError
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we are forced to reload the appropriate component in the test. Am I correct in understanding you're removing the need for that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this has been a source of flakiness in tests since forever. Hopefully we should see a reduction in flakiness with this change.

Copy link
Copy Markdown
Contributor

@pkmiec pkmiec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I added a couple small comments as food for thought.

ensure_loaded!
self
end

Copy link
Copy Markdown
Contributor

@pkmiec pkmiec May 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever! what do you think about using aepos-reloading to reduce the chance of name collisions?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done.

Comment thread .travis.yml Outdated

addons:
firefox: "23.0"
firefox: "58.0.1"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious. have you tried FF 59.x?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give it a go.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@sarahsehr sarahsehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should definitely get another review, but other than what I indicated I didn't understand, this seems reasonable.

@tlconnor tlconnor merged commit 658bd10 into master May 4, 2018
@tlconnor tlconnor deleted the capybara3 branch May 4, 2018 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants