Search code examples
ruby-on-railsrspecwebkitcapybaracapybara-webkit

Capybara Webkit on Shopify


Hi I am writing feature test on Shopify installation. And before that I want to delete it, so I can make fresh installation. But I fail to do that in normal way, because it responds with:

Please upgrade your browser Your browser is not supported by Shopify. We recommend Google Chrome, however the latest versions of Safari, Firefox, and Internet Explorer work great too. You may continue using your old browser but some features may not work correctly. We recommend Google Chrome

What I do is:

  scenario 'registers goes through basic setup', js: true do    
    visit 'https://uid.myshopify.com/admin/apps'
    fill_in 'login-input', with: 'email@email.email'
    fill_in 'password', with: '***'
    find('input[type="submit"]').click
  end

My Gemfile:

 group :development, :test do
  gem 'rspec-rails'
  gem 'capybara'
  gem 'capybara-webkit'
  gem 'selenium-webdriver'
  # gem 'capybara-email'
  gem 'factory_girl'
  gem 'factory_girl_rails'
  gem 'launchy'
  gem 'database_cleaner'
  gem 'colorize'
end

And: Capybara.javascript_driver = :webkit

So is there a way of forcing javascript all the time. Because in later use it says that I need to enable javascript.

If you think that js is not working in all tests, that then it is wrong, as in other tests where I don't use Shopify, all is perfect.


Solution

  • Since it looks you're using capybara-webkit as the driver - to set the user agent you should be able to do

    page.driver.header 'User-Agent', '<whatever user agent string you need>'
    

    before visiting the page.

    To force javascript support all the time do

    Capybara.default_driver = :webkit