Skip to content

Commit

Permalink
Only use visibility optimization if atom is available
Browse files Browse the repository at this point in the history
Test base versions
  • Loading branch information
twalpole committed Jan 24, 2019
1 parent 05c23c8 commit eaf245a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ matrix:
env:
- CAPYBARA_REMOTE=true
- CAPYBARA_FF=true
- gemfile: gemfiles/Gemfile.rspec-35
- gemfile: gemfiles/Gemfile.base-versions
rvm: 2.3.8
env: CAPYBARA_FF=true
addons:
Expand Down
7 changes: 7 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Version 3.13.1
Release date: 2019-01-24

### Fixed

* Only use Selenium visibility optimization when JS atom is available - Issue #2151

# Version 3.13.0
Release date: 2019-01-23

Expand Down
10 changes: 10 additions & 0 deletions gemfiles/Gemfile.base-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

gem 'bundler', '< 3.0'
gemspec path: '..'

gem 'rack', '1.6.0'
gem 'nokogiri', '~>1.8.0'
gem 'xpath', '~>3.2.0'
gem 'rspec', '~>3.5.0'
gem 'selenium-webdriver', '~>3.5.0'
7 changes: 0 additions & 7 deletions gemfiles/Gemfile.rspec-35

This file was deleted.

11 changes: 9 additions & 2 deletions lib/capybara/selenium/extensions/find.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ def find_css(selector, uses_visibility: false, texts: [], styles: nil, **_option
def find_by(format, selector, uses_visibility:, texts:, styles:)
els = find_context.find_elements(format, selector)
hints = []

if (els.size > 2) && !ENV['DISABLE_CAPYBARA_SELENIUM_OPTIMIZATIONS']
els = filter_by_text(els, texts) unless texts.empty?

hints_js = +''
functions = []
if uses_visibility
if uses_visibility && !is_displayed_atom.empty?
puts "running vis func"
hints_js << <<~VISIBILITY_JS
var vis_func = #{is_displayed_atom};
VISIBILITY_JS
Expand Down Expand Up @@ -74,7 +76,12 @@ def es_context
end

def is_displayed_atom # rubocop:disable Naming/PredicateName
@@is_displayed_atom ||= browser.send(:bridge).send(:read_atom, 'isDisplayed')
@@is_displayed_atom ||= begin
browser.send(:bridge).send(:read_atom, 'isDisplayed')
rescue StandardError
# If the atom doesn't exist or other error
""
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class TestClass
case example.metadata[:full_description]
when /has_css\? should support case insensitive :class and :id options/
pending "Nokogiri doesn't support case insensitive CSS attribute matchers"
when /#click_button should follow permanent redirects that maintain method/
pending "Rack < 2 doesn't support 308" if Gem.loaded_specs['rack'].version < Gem::Version.new('2.0.0')
end
end

Expand Down
4 changes: 3 additions & 1 deletion spec/rack_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ module TestSessions
Capybara::SpecHelper.run_specs TestSessions::RackTest, 'RackTest', capybara_skip: skipped_tests do |example|
case example.metadata[:full_description]
when /has_css\? should support case insensitive :class and :id options/
pending "Nokogiri doesn't support case insensitive CSS attribute matchers"
skip "Nokogiri doesn't support case insensitive CSS attribute matchers"
when /#click_button should follow permanent redirects that maintain method/
skip "Rack < 2 doesn't support 308" if Gem.loaded_specs['rack'].version < Gem::Version.new('2.0.0')
end
end

Expand Down

0 comments on commit eaf245a

Please sign in to comment.