percy / percy-capybara

Visual testing for Capybara with Percy.
https://docs.percy.io/docs/capybara
MIT License
45 stars 23 forks source link

Background images specified as inline styles not working in rack test #14

Closed j-clark closed 3 years ago

j-clark commented 7 years ago

Hi there!

It looks like background images specified as inline styles only work for javascript-enabled drivers

https://github.com/percy/percy-capybara/blob/master/lib/percy/capybara/loaders/native_loader.rb#L119-L123

This is a half-baked suggestion, but how about something along these lines to support rack-test?

page
  .all('[style]')
  .select { |el| el['style'] && el['style'].include?('background') }
  .map { |el| parse_url(el['style']) }

def parse_url(style_attribute)
  # do some regexing or something
end

Any thoughts?