{"id":13428096,"url":"https://github.com/thoughtbot/capybara-webkit","last_synced_at":"2025-09-28T21:30:47.720Z","repository":{"id":56842927,"uuid":"1409544","full_name":"thoughtbot/capybara-webkit","owner":"thoughtbot","description":"A Capybara driver for headless WebKit to test JavaScript web apps","archived":true,"fork":false,"pushed_at":"2020-03-03T15:09:01.000Z","size":1642,"stargazers_count":1976,"open_issues_count":30,"forks_count":432,"subscribers_count":83,"default_branch":"master","last_synced_at":"2024-04-14T09:45:22.218Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://thoughtbot.com/open-source","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thoughtbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-02-25T03:46:54.000Z","updated_at":"2024-04-12T14:20:44.000Z","dependencies_parsed_at":"2022-08-20T11:40:36.453Z","dependency_job_id":null,"html_url":"https://github.com/thoughtbot/capybara-webkit","commit_stats":null,"previous_names":[],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtbot%2Fcapybara-webkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtbot%2Fcapybara-webkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtbot%2Fcapybara-webkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtbot%2Fcapybara-webkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thoughtbot","download_url":"https://codeload.github.com/thoughtbot/capybara-webkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234563136,"owners_count":18853060,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T01:00:46.012Z","updated_at":"2025-09-28T21:30:47.011Z","avatar_url":"https://github.com/thoughtbot.png","language":"Ruby","readme":"capybara-webkit\n===============\n\n**Development has been suspended** on this project because QtWebKit was\ndeprecated in favor of QtWebEngine, which is not a suitable replacement for our\npurposes.\n\nWe instead recommend using the [Selenium] or [Apparition] drivers.\n\n[Selenium]: https://github.com/teamcapybara/capybara#selenium\n[Apparition]: https://github.com/twalpole/apparition\n\nQt Dependency and Installation Issues\n-------------------------------------\n\ncapybara-webkit depends on a WebKit implementation from Qt, a cross-platform\ndevelopment toolkit. You'll need to download the Qt libraries to build and\ninstall the gem. You can find instructions for downloading and installing Qt on\nthe\n[capybara-webkit wiki](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit).\ncapybara-webkit requires Qt version 4.8 or greater.\n\nCI\n--\n\nIf you're like us, you'll be using capybara-webkit on CI.\n\nOn Linux platforms, capybara-webkit requires an X server to run, although it doesn't create any visible windows. Xvfb works fine for this. You can setup Xvfb yourself and set a DISPLAY variable, try out the [headless gem](https://github.com/leonid-shevtsov/headless), or use the xvfb-run utility as follows:\n\n```\nxvfb-run -a bundle exec rspec\n```\n\nThis automatically sets up a virtual X server on a free server number.\n\nUsage\n-----\n\nAdd the capybara-webkit gem to your Gemfile:\n\n```ruby\ngem \"capybara-webkit\"\n```\n\nSet your Capybara Javascript driver to webkit:\n\n```ruby\nCapybara.javascript_driver = :webkit\n```\n\nIn cucumber, tag scenarios with @javascript to run them using a headless WebKit browser.\n\nIn RSpec, use the `:js =\u003e true` flag. See the [capybara documentation](http://rubydoc.info/gems/capybara#Using_Capybara_with_RSpec) for more information about using capybara with RSpec.\n\nTake note of the transactional fixtures section of the [capybara README](https://github.com/jnicklas/capybara/blob/master/README.md).\n\nIf you're using capybara-webkit with Sinatra, don't forget to set\n\n```ruby\nCapybara.app = MySinatraApp.new\n```\n\nConfiguration\n-------------\n\nYou can configure global options using `Capybara::Webkit.configure`:\n\n``` ruby\nCapybara::Webkit.configure do |config|\n  # Enable debug mode. Prints a log of everything the driver is doing.\n  config.debug = true\n\n  # By default, requests to outside domains (anything besides localhost) will\n  # result in a warning. Several methods allow you to change this behavior.\n\n  # Silently return an empty 200 response for any requests to unknown URLs.\n  config.block_unknown_urls\n\n  # Allow pages to make requests to any URL without issuing a warning.\n  config.allow_unknown_urls\n\n  # Allow a specific domain without issuing a warning.\n  config.allow_url(\"example.com\")\n\n  # Allow a specific URL and path without issuing a warning.\n  config.allow_url(\"example.com/some/path\")\n\n  # Wildcards are allowed in URL expressions.\n  config.allow_url(\"*.example.com\")\n\n  # Silently return an empty 200 response for any requests to the given URL.\n  config.block_url(\"example.com\")\n\n  # Timeout if requests take longer than 5 seconds\n  config.timeout = 5\n\n  # Don't raise errors when SSL certificates can't be validated\n  config.ignore_ssl_errors\n\n  # Don't load images\n  config.skip_image_loading\n\n  # Use a proxy\n  config.use_proxy(\n    host: \"example.com\",\n    port: 1234,\n    user: \"proxy\",\n    pass: \"secret\"\n  )\n\n  # Raise JavaScript errors as exceptions\n  config.raise_javascript_errors = true\nend\n```\n\nThese options will take effect for all future sessions and only need to be set\nonce. It's recommended that you configure these in your `spec_helper.rb` or\n`test_helper.rb` rather than a `before` or `setup` block.\n\nOffline Application Cache\n-------------------------\n\nThe offline application cache needs a directory to write to for the cached files. Capybara-webkit\nwill look at if the working directory has a tmp directory and when it exists offline application\ncache will be enabled.\n\nNon-Standard Driver Methods\n---------------------------\n\ncapybara-webkit supports a few methods that are not part of the standard capybara API. You can access these by calling `driver` on the capybara session. When using the DSL, that will look like `page.driver.method_name`.\n\n**console_messages**: returns an array of messages printed using console.log\n\n```js\n// In Javascript:\nconsole.log(\"hello\")\n```\n\n```ruby\n# In Ruby:\npage.driver.console_messages\n=\u003e [{:source=\u003e\"http://example.com\", :line_number=\u003e1, :message=\u003e\"hello\"}]\n```\n\n**error_messages**: returns an array of Javascript errors that occurred\n\n```ruby\npage.driver.error_messages\n=\u003e [{:source=\u003e\"http://example.com\", :line_number=\u003e1, :message=\u003e\"SyntaxError: Parse error\"}]\n```\n\n**cookies**: allows read-only access of cookies for the current session\n\n```ruby\npage.driver.cookies[\"alpha\"]\n=\u003e \"abc\"\n```\n\n**header**: set the given HTTP header for subsequent requests\n\n```ruby\npage.driver.header 'Referer', 'https://www.thoughtbot.com'\n```\n\n\n[CONTRIBUTING]: CONTRIBUTING.md\n\nLicense\n-------\n\ncapybara-webkit is Copyright (c) 2010-2015 thoughtbot, inc. It is free software,\nand may be redistributed under the terms specified in the [LICENSE] file.\n\n[LICENSE]: /LICENSE\n\nAbout\n-----\n\nThank you, [contributors]!\n\n[contributors]: https://github.com/thoughtbot/capybara-webkit/graphs/contributors\n\nCode for rendering the current webpage to a PNG is borrowed from Phantom.js'\nimplementation.\n\n![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)\n\ncapybara-webkit is maintained and funded by thoughtbot, inc.\nThe names and logos for thoughtbot are trademarks of thoughtbot, inc.\n\nWe love open source software!\nSee [our other projects][community]\nor [hire us][hire] to help build your product.\n\n[community]: https://thoughtbot.com/community?utm_source=github\n[hire]: https://thoughtbot.com/hire-us?utm_source=github\n","funding_links":[],"categories":["Testing","测试","Gems"],"sub_categories":["Omniauth","Browser testing","Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoughtbot%2Fcapybara-webkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoughtbot%2Fcapybara-webkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoughtbot%2Fcapybara-webkit/lists"}