[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7965":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":16,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":20,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":16,"starSnapshotCount":16,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},7965,"poltergeist","teampoltergeist\u002Fpoltergeist","teampoltergeist","A PhantomJS driver for Capybara","",null,"Ruby",2486,409,1,10,0,59.84,"MIT License",true,false,"master",[],"2026-06-12 04:00:36","# Poltergeist - A PhantomJS driver for Capybara #\n\n[![Build Status](https:\u002F\u002Fsecure.travis-ci.org\u002Fteampoltergeist\u002Fpoltergeist.svg)](http:\u002F\u002Ftravis-ci.org\u002Fteampoltergeist\u002Fpoltergeist)\n\nPoltergeist is a driver for [Capybara](https:\u002F\u002Fgithub.com\u002Fjnicklas\u002Fcapybara). It allows you to\nrun your Capybara tests on a headless PhantomJS browser. If you would like to run your tests on headless Chrome there's another project [Cuprite](https:\u002F\u002Fgithub.com\u002Fmachinio\u002Fcuprite) claims to be compatible with Poltergeist.\n\n**If you're viewing this at https:\u002F\u002Fgithub.com\u002Fteampoltergeist\u002Fpoltergeist,\nyou're reading the documentation for the master branch.\n[View documentation for the latest release\n(1.18.1).](https:\u002F\u002Fgithub.com\u002Fteampoltergeist\u002Fpoltergeist\u002Ftree\u002Fv1.18.1)**\n\n## Getting help ##\n\nQuestions should be posted [on Stack\nOverflow, using the 'poltergeist' tag](http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002Ftagged\u002Fpoltergeist).\n\nBug reports should be posted [on\nGitHub](https:\u002F\u002Fgithub.com\u002Fteampoltergeist\u002Fpoltergeist\u002Fissues) (and be sure\nto read the bug reporting guidance below).\n\n## Installation ##\n\nAdd this line to your Gemfile and run `bundle install`:\n\n``` ruby\ngem 'poltergeist'\n```\n\nIn your test setup add:\n\n``` ruby\nrequire 'capybara\u002Fpoltergeist'\nCapybara.javascript_driver = :poltergeist\n```\n\nIf you were previously using the `:rack_test` driver, be aware that\nyour app will now run in a separate thread and this can have\nconsequences for transactional tests. [See the Capybara README for more\ndetail](https:\u002F\u002Fgithub.com\u002Fjnicklas\u002Fcapybara\u002Fblob\u002Fmaster\u002FREADME.md#transactions-and-database-setup).\n\n## Installing PhantomJS ##\n\nYou need at least PhantomJS 1.8.1.  There are *no other external\ndependencies* (you don't need Qt, or a running X server, etc.)\n\n### Mac ###\n\n* *Homebrew*: `brew tap homebrew\u002Fcask && brew cask install phantomjs`\n* *MacPorts*: `sudo port install phantomjs`\n* *Manual install*: [Download this](https:\u002F\u002Fbitbucket.org\u002Fariya\u002Fphantomjs\u002Fdownloads\u002Fphantomjs-1.9.8-macosx.zip)\n\n### Linux ###\n\n* Download the [32 bit](https:\u002F\u002Fbitbucket.org\u002Fariya\u002Fphantomjs\u002Fdownloads\u002Fphantomjs-2.1.1-linux-i686.tar.bz2)\nor [64 bit](https:\u002F\u002Fbitbucket.org\u002Fariya\u002Fphantomjs\u002Fdownloads\u002Fphantomjs-2.1.1-linux-x86_64.tar.bz2)\nbinary.\n* Extract the tarball and copy `bin\u002Fphantomjs` into your `PATH`\n\n_DO NOT_ use `phantomjs` from the official Ubuntu repositories, since it doesn't\nwork well with `poltergeist`. More information\n[here](https:\u002F\u002Fgithub.com\u002Fteampoltergeist\u002Fpoltergeist\u002Fissues\u002F866).\n\n### Windows ###\n* Download the [precompiled binary](https:\u002F\u002Fbitbucket.org\u002Fariya\u002Fphantomjs\u002Fdownloads\u002Fphantomjs-1.9.8-windows.zip)\nfor Windows\n\n### Manual compilation ###\n\nDo this as a last resort if the binaries don't work for you. It will\ntake quite a long time as it has to build WebKit.\n\n* Download [the source tarball](https:\u002F\u002Fbitbucket.org\u002Fariya\u002Fphantomjs\u002Fdownloads\u002Fphantomjs-1.9.8-source.zip)\n* Extract and cd in\n* `.\u002Fbuild.sh`\n\n(See also the [PhantomJS building\nguide](http:\u002F\u002Fphantomjs.org\u002Fbuild.html).)\n\n## Compatibility ##\n\nPoltergeist runs on MRI 1.9+, JRuby 1.9+ and Rubinius 1.9+. Poltergeist\nand PhantomJS are currently supported on Mac OS X, Linux, and Windows\nplatforms.\n\nRuby 1.8 is no longer supported. The last release to support Ruby 1.8\nwas 1.0.2, so you should use that if you still need Ruby 1.8 support.\n\nPhantomJS does not support ES6 features at the time of writing this\ndocument. Setting `js_errors` to `true` can help determine if failing\ntests require Polyfills, although a bug in PhantomJS can cause silent\nfailures if using ES6 features like `let`, `const`, etc.\n\n## Running on a CI ##\n\nThere are no special steps to take. You don't need Xvfb or any running X\nserver at all.\n\n[Travis CI](https:\u002F\u002Ftravis-ci.org\u002F), [CircleCI](https:\u002F\u002Fcircleci.com\u002F),\n[Codeship](https:\u002F\u002Fcodeship.com\u002F) and [Semaphore](https:\u002F\u002Fsemaphoreci.com\u002F)\nhave PhantomJS pre-installed.\n\nDepending on your tests, one thing that you may need is some fonts. If\nyou're getting errors on a CI that don't occur during development then\ntry taking some screenshots - it may well be missing fonts throwing\nthings off kilter. Your distro will have various font packages available\nto install.\n\n## What's supported? ##\n\nPoltergeist supports all the mandatory features for a Capybara driver,\nand the following optional features:\n\n* `page.evaluate_script` and `page.execute_script`\n* `page.within_frame`\n* `page.status_code`\n* `page.response_headers`\n* `page.save_screenshot`\n* `page.driver.render_base64(format, options)`\n* `page.driver.scroll_to(left, top)`\n* `page.driver.basic_authorize(user, password)`\n* `element.send_keys(*keys)`\n* `page.driver.set_proxy(ip, port, type, user, password)`\n* window API\n* cookie handling\n* drag-and-drop\n\nThere are some additional features:\n\n### Taking screenshots with some extensions ###\n\nYou can grab screenshots of the page at any point by calling\n`save_screenshot('\u002Fpath\u002Fto\u002Ffile.png')` (this works the same way as the PhantomJS\nrender feature, so you can specify other extensions like `.pdf`, `.gif`, etc.)\nJust in case you render pdf it's might be worth to set `driver.paper_size=` with\nsettings provided by PhantomJS in [here](https:\u002F\u002Fgithub.com\u002Fariya\u002Fphantomjs\u002Fwiki\u002FAPI-Reference-WebPage#wiki-webpage-paperSize)\n\nBy default, only the viewport will be rendered (the part of the page that is in\nview). To render the entire page, use `save_screenshot('\u002Fpath\u002Fto\u002Ffile.png',\n:full => true)`.\n\nYou also have an ability to render selected element. Pass option `selector` with\nany valid CSS element selector to make a screenshot bounded by that element\n`save_screenshot('\u002Fpath\u002Fto\u002Ffile.png', :selector => '#id')`.\n\nIf you need for some reasons base64 encoded screenshot you can simply call\n`render_base64` that will return you encoded image. Additional options are the\nsame as for `save_screenshot` except the first argument which is format (:png by\ndefault, acceptable :png, :gif, :jpeg).\n\n### Clicking precise coordinates ###\n\nSometimes its desirable to click a very specific area of the screen. You can accomplish this with\n`page.driver.click(x, y)`, where x and y are the screen coordinates.\n\n### Remote debugging (experimental) ###\n\nIf you use the `:inspector => true` option (see below), remote debugging\nwill be enabled.\n\nWhen this option is enabled, you can insert `page.driver.debug` into\nyour tests to pause the test and launch a browser which gives you the\nWebKit inspector to view your test run with.\n\nYou can register this debugger driver with a different name and set it\nas the current javascript driver. By example, in your helper file:\n\n```ruby\nCapybara.register_driver :poltergeist_debug do |app|\n  Capybara::Poltergeist::Driver.new(app, :inspector => true)\nend\n\n# Capybara.javascript_driver = :poltergeist\nCapybara.javascript_driver = :poltergeist_debug\n```\n\n[Read more\nhere](http:\u002F\u002Fjonathanleighton.com\u002Farticles\u002F2012\u002Fpoltergeist-0-6-0\u002F)\n\n### Manipulating request headers ###\n\nYou can manipulate HTTP request headers with these methods:\n\n``` ruby\npage.driver.headers # => {}\npage.driver.headers = { \"User-Agent\" => \"Poltergeist\" }\npage.driver.add_headers(\"Referer\" => \"https:\u002F\u002Fexample.com\")\npage.driver.headers # => { \"User-Agent\" => \"Poltergeist\", \"Referer\" => \"https:\u002F\u002Fexample.com\" }\n```\n\nNotice that `headers=` will overwrite already set headers. You should use\n`add_headers` if you want to add a few more. These headers will apply to all\nsubsequent HTTP requests (including requests for assets, AJAX, etc). They will\nbe automatically cleared at the end of the test. You have ability to set headers\nonly for the initial request:\n\n``` ruby\npage.driver.headers = { \"User-Agent\" => \"Poltergeist\" }\npage.driver.add_header(\"Referer\", \"http:\u002F\u002Fexample.com\", permanent: false)\npage.driver.headers # => { \"User-Agent\" => \"Poltergeist\", \"Referer\" => \"http:\u002F\u002Fexample.com\" }\nvisit(login_path)\npage.driver.headers # => { \"User-Agent\" => \"Poltergeist\" }\n```\n\nThis way your temporary headers will be sent only for the initial request, and related 30x redirects. All\nsubsequent request will only contain your permanent headers. If the temporary\nheaders should not be sent on related 30x redirects, specify `permanent: :no_redirect`.\n\nHeaders set with any of these methods will be set within all windows in the\nsession, with the exception of temporary headers, which are only set within the\ncurrent window.\n\n### Inspecting network traffic ###\n\nYou can inspect the network traffic (i.e. what resources have been\nloaded) on the current page by calling `page.driver.network_traffic`.\nThis returns an array of request objects. A request object has a\n`response_parts` method containing data about the response chunks.\n\nYou can inspect requests that were blocked by a whitelist or blacklist\nby calling `page.driver.network_traffic(:blocked)`. This returns an array of\nrequest objects. The `response_parts` portion of these requests will always\nbe empty.\n\nPlease note that network traffic is not cleared when you visit new page.\nYou can manually clear the network traffic by calling `page.driver.clear_network_traffic`\nor `page.driver.reset`\n\n### Manipulating cookies ###\n\nThe following methods are used to inspect and manipulate cookies:\n\n* `page.driver.cookies` - a hash of cookies accessible to the current\n  page. The keys are cookie names. The values are `Cookie` objects, with\n  the following methods: `name`, `value`, `domain`, `path`, `secure?`,\n  `httponly?`, `samesite`, `expires`.\n* `page.driver.set_cookie(name, value, options = {})` - set a cookie.\n  The options hash can take the following keys: `:domain`, `:path`,\n  `:secure`, `:httponly`, `:samesite`, `:expires`. `:expires` should be a\n  `Time` object.\n* `page.driver.remove_cookie(name)` - remove a cookie\n* `page.driver.clear_cookies` - clear all cookies\n\n### Sending keys ###\n\nThere's an ability to send arbitrary keys to the element:\n\n``` ruby\nelement = find('input#id')\nelement.send_keys('String')\n```\n\nor even more complicated:\n\n``` ruby\nelement.send_keys('H', 'elo', :left, 'l') # => 'Hello'\nelement.send_keys(:enter) # triggers Enter key\n```\nSince it's implemented natively in PhantomJS this will exactly imitate user\nbehavior.\nSee more about [sendEvent](http:\u002F\u002Fphantomjs.org\u002Fapi\u002Fwebpage\u002Fmethod\u002Fsend-event.html) and\n[PhantomJS keys](https:\u002F\u002Fgithub.com\u002Fariya\u002Fphantomjs\u002Fcommit\u002Fcab2635e66d74b7e665c44400b8b20a8f225153a)\n\n## Customization ##\n\nYou can customize the way that Capybara sets up Poltergeist via the following code in your\ntest setup:\n\n``` ruby\nCapybara.register_driver :poltergeist do |app|\n  Capybara::Poltergeist::Driver.new(app, options)\nend\n```\n\n`options` is a hash of options. The following options are supported:\n\n*   `:phantomjs` (String) - A custom path to the phantomjs executable\n*   `:debug` (Boolean) - When true, debug output is logged to `STDERR`.\n    Some debug info from the PhantomJS portion of Poltergeist is also\n    output, but this goes to `STDOUT` due to technical limitations.\n*   `:logger` (Object responding to `puts`) - When present, debug output is written to this object\n*   `:phantomjs_logger` (`IO` object) - Where the `STDOUT` from PhantomJS is written to. This is\n    where your `console.log` statements will show up. Default: `STDOUT`\n*   `:timeout` (Numeric) - The number of seconds we'll wait for a response\n    when communicating with PhantomJS. Default is 30.\n*   `:inspector` (Boolean, String) - See 'Remote Debugging', above.\n*   `:js_errors` (Boolean) - When false, JavaScript errors do not get re-raised in Ruby.\n*   `:window_size` (Array) - The dimensions of the browser window in which to test, expressed\n    as a 2-element array, e.g. [1024, 768]. Default: [1024, 768]\n*   `:screen_size` (Array) - The dimensions the window size will be set to when Window#maximize is called.  Expressed\n    as a 2-element array, e.g. [1600, 1200]. Default: [1366, 768]\n*   `:phantomjs_options` (Array) - Additional [command line options](http:\u002F\u002Fphantomjs.org\u002Fapi\u002Fcommand-line.html)\n    to be passed to PhantomJS, e.g. `['--load-images=no', '--ignore-ssl-errors=yes']`\n*   `:extensions` (Array) - An array of JS files to be preloaded into\n    the phantomjs browser. Useful for faking unsupported APIs.\n*   `:port` (Fixnum) - The port which should be used to communicate with the PhantomJS process. Defaults to a random open port.\n*   `:host` (String) - The name or IP of the PhantomJS host. Default is '127.0.0.1'.\n*   `:url_blacklist` (Array) - Default session url blacklist - expressed as an array of strings to match against requested URLs.\n*   `:url_whitelist` (Array) - Default session url whitelist - expressed as an array of strings to match against requested URLs.\n*   `:page_settings` (Hash) - PhantomJS web page settings (http:\u002F\u002Fphantomjs.org\u002Fapi\u002Fwebpage\u002Fproperty\u002Fsettings.html).\n\n### URL Blacklisting & Whitelisting ###\nPoltergeist supports URL blacklisting, which allows you\nto prevent scripts from running on designated domains:\n\n```ruby\npage.driver.browser.url_blacklist = ['http:\u002F\u002Fwww.example.com']\n```\n\nand also URL whitelisting, which allows scripts to only run\non designated domains:\n\n```ruby\npage.driver.browser.url_whitelist = ['http:\u002F\u002Fwww.example.com']\n```\n\nIf you are experiencing slower run times, consider creating a\nURL whitelist of domains that are essential or a blacklist of\ndomains that are not essential, such as ad networks or analytics,\nto your testing environment.\n\n\n## Troubleshooting ##\n\nUnfortunately, the nature of full-stack testing is that things can and\ndo go wrong from time to time. This section aims to highlight a number\nof common problems and provide ideas about how you can work around them.\n\n### DeadClient errors ###\n\nSometimes PhantomJS crashes during a test. There are basically two kinds\nof crashes: those that can be reproduced every time, and those that\noccur sporadically and are not easily reproduced.\n\nIf your crash happens every time, you should read the [PhantomJS crash\nreporting\nguide](http:\u002F\u002Fphantomjs.org\u002Fcrash-reporting.html) and file\na bug against PhantomJS. Feel free to also file a bug against\nPoltergeist in case there are workarounds that can be implemented within\nPoltergeist. Also, if lots of Poltergeist users are experiencing the\nsame crash then fixing it will move up the priority list.\n\nIf your crash is sporadic, there is less that can be done. Often these\nissues are very complicated and difficult to track down. It may be that\nthe crash has already been fixed in a newer version of WebKit that will\neventually find its way into PhantomJS. It's still worth reporting your\nbug against PhantomJS, but it's probably not worth filing a bug against\nPoltergeist as there's not much we can do.\n\nIf you experience sporadic crashes a lot, it may be worth configuring\nyour CI to automatically re-run failing tests before reporting a failed\nbuild.\n\n### MouseEventFailed errors ###\n\nWhen Poltergeist clicks on an element, rather than generating a DOM\nclick event, it actually generates a \"proper\" click. This is much closer\nto what happens when a real user clicks on the page - but it means that\nPoltergeist must scroll the page to where the element is, and work out\nthe correct co-ordinates to click. If the element is covered up by\nanother element, the click will fail (this is a good thing - because\nyour user won't be able to click a covered up element either).\n\nSometimes there can be issues with this behavior. If you have problems,\nit's worth taking screenshots of the page and trying to work out what's\ngoing on. If your click is failing, but you're not getting a\n`MouseEventFailed` error, then you can turn on the `:debug` option and look\nin the output to see what co-ordinates Poltergeist is using for the\nclick. You can then cross-reference this with a screenshot to see if\nsomething is obviously wrong.\n\nIf you can't figure out what's going on and just want to work around the\nproblem so you can get on with life, consider using a DOM click\nevent. For example, if this code is failing:\n\n``` ruby\nclick_button \"Save\"\n```\n\nThen try:\n\n``` ruby\nfind_button(\"Save\").trigger('click')\n```\n\n### Timing problems ###\n\nSometimes tests pass and fail sporadically. This is often because there\nis some problem synchronising events properly. It's often\nstraightforward to verify this by adding `sleep` statements into your\ntest to allow sufficient time for the page to settle.\n\nIf you have these types of problems, read through the [Capybara\ndocumentation on asynchronous\nJavaScript](https:\u002F\u002Fgithub.com\u002Fjnicklas\u002Fcapybara#asynchronous-javascript-ajax-and-friends)\nwhich explains the tools that Capybara provides for dealing with this.\n\n### Memory leak ###\n\nIf you run a few capybara sessions manually please make sure you've called\n`session.driver.quit` when you don't need session anymore. Forgetting about this\ncauses memory leakage and your system's resources can be exhausted earlier than\nyou may expect.\n\n### General troubleshooting hints ###\n\n* Configure Poltergeist with `:debug` turned on so you can see its\n  communication with PhantomJS.\n* Take screenshots to figure out what the state of your page is when the\n  problem occurs.\n* Use the remote web inspector in case it provides any useful insight\n* Consider downloading the Poltergeist source and using `console.log`\n  debugging to figure out what's going on inside PhantomJS. (This will\n  require an understanding of the Poltergeist source code and PhantomJS,\n  so it's only for the committed!)\n\n### Filing a bug ###\n\nIf you can provide specific steps to reproduce your problem, or have\nspecific information that might help other help you track down the\nproblem, then please file a bug on Github.\n\nInclude as much information as possible. For example:\n\n* Specific steps to reproduce where possible (failing tests are even\n  better)\n* The output obtained from running Poltergeist with `:debug` turned on\n* Screenshots\n* Stack traces if there are any Ruby on JavaScript exceptions generated\n* The Poltergeist and PhantomJS version numbers used\n* The operating system name and version used\n\n## Changes ##\n\nVersion history and a list of next-release features and fixes can be found in\nthe [changelog](CHANGELOG.md).\n\n## License ##\n\nCopyright (c) 2011-2015 Jonathan Leighton\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and\u002For sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","Poltergeist 是一个用于 Capybara 的 PhantomJS 驱动程序，它允许用户在无头 PhantomJS 浏览器上运行 Capybara 测试。其核心功能是提供了一种方式让 Ruby 开发者能够在没有图形界面的情况下执行自动化浏览器测试，特别适合于需要JavaScript支持的Web应用测试场景。Poltergeist 通过与Capybara无缝集成，为开发者提供了便捷的测试解决方案，而无需额外依赖如Qt或X服务器等环境。此外，该项目易于安装和配置，仅需确保安装了至少1.8.1版本以上的PhantomJS即可开始使用，适用于希望提高测试效率并减少资源消耗的各种开发团队。",2,"2026-06-11 03:15:23","top_language"]