Search code examples
rubyrspeccapybaraacceptance-testingcapybara-webkit

Disable sound in capybara-webkit


I'm running a website signup spec with

Capybara.javascript_driver = :webkit

I noticed that when the test completes the signup, the "successful signup" sound (the one that can be heard when signing up from a "normal" browser) starts.

I think this is the normal behaviour, but my questions are:

  • Is there a way to disable sounds in capybara-webkit?
  • Is there a way to mute the browser instance?

Like when we want to not load images and we use config.skip_image_loading


Solution

  • It seems that capybara-webkit doesn't expose this setting, as Qt (capybara-webkit depends on a WebKit implementation from Qt) doesn't expose it either.

    Ref: https://github.com/thoughtbot/capybara-webkit/issues/555

    But you probably can achieve it with other approaches like:

    • Execute javascript to remove the audio tags or mute the player:

    page.execute_script("your_js_here")

    • Block the audio urls:

    config.block_url("example.com/path_to_audio_files/*")