{"id":13471968,"url":"https://github.com/detro/ghostdriver","last_synced_at":"2025-05-14T15:06:47.249Z","repository":{"id":2790305,"uuid":"3790293","full_name":"detro/ghostdriver","owner":"detro","description":"Ghost Driver is an implementation of the Remote WebDriver Wire protocol, using PhantomJS as back-end","archived":false,"fork":false,"pushed_at":"2019-02-08T16:23:10.000Z","size":7008,"stargazers_count":1910,"open_issues_count":156,"forks_count":334,"subscribers_count":115,"default_branch":"master","last_synced_at":"2025-04-09T06:00:39.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/detro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.BSD","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-21T19:09:32.000Z","updated_at":"2025-03-21T21:09:25.000Z","dependencies_parsed_at":"2022-09-10T14:01:29.044Z","dependency_job_id":null,"html_url":"https://github.com/detro/ghostdriver","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/detro%2Fghostdriver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/detro%2Fghostdriver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/detro%2Fghostdriver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/detro%2Fghostdriver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/detro","download_url":"https://codeload.github.com/detro/ghostdriver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254169227,"owners_count":22026209,"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-31T16:00:50.768Z","updated_at":"2025-05-14T15:06:47.228Z","avatar_url":"https://github.com/detro.png","language":"Java","readme":"[![Release](https://jitpack.io/v/detro/ghostdriver.svg)](https://jitpack.io/#detro/ghostdriver)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdetro%2Fghostdriver.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdetro%2Fghostdriver?ref=badge_shield)\n\n# Ghost Driver\n\nGhost Driver is a pure JavaScript implementation of the\n[WebDriver Wire Protocol](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol)\nfor [PhantomJS](http://phantomjs.org/).\nIt's a Remote WebDriver that uses PhantomJS as back-end.\n\n**GhostDriver is designed to be integral part of PhantomJS itself, but it's developed in isolation and progress is tracked\nby this Repository.**\n\n* Current _GhostDriver_ stable version:\nsee [releases](https://github.com/detro/ghostdriver/releases)\n* PhantomJS-integrated version is `\"1.2.0\"` (detro@2af7099a9) :\ncontained in PhantomJS `\"2.1.1\"`\n* Current _PhantomJSDriver Java bindings_ stable version: see\n[Maven](https://oss.sonatype.org/index.html#nexus-search;quick~phantomjsdriver)\n\nFor more info, please take a look at the [changelog](https://github.com/detro/ghostdriver/blob/master/CHANGELOG.md).\n\nThe project was created and is lead by [Ivan De Marino](https://github.com/detro).\n\nIRC channel: [#phantomjs-ghostdriver](http://webchat.freenode.net/?channels=%23phantomjs-ghostdriver).\n\n## Setup\n\n* Download latest stable PhantomJS from [here](http://phantomjs.org/download.html)\n* Selenium version `\"\u003e= 3.1.0`\"\n\n**THAT'S IT!!** Because of latest stable GhostDriver being embedded in PhantomJS,\nyou shouldn't need anything else to get started.\n\n## Register GhostDriver with a Selenium Grid hub\n\n1. Launch the grid server, which listens on 4444 by default: `java -jar /path/to/selenium-server-standalone-\u003cSELENIUM VERSION\u003e.jar -role hub`\n2. Register with the hub: `phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444`\n3. Now you can use your normal webdriver client with `http://127.0.0.1:4444` and just request `browserName: phantomjs`\n\n## (Java) Bindings\n\nThis project provides WebDriver bindings for Java under the name _PhantomJSDriver_.\n[Here is the JavaDoc](https://cdn.rawgit.com/detro/ghostdriver/master/binding/java/docs/javadoc/index.html).\n\nBindings for other languages (C#, Python, Ruby, ...) are developed and maintained\nunder the same name within the [Selenium project](http://docs.seleniumhq.org/docs/) itself.\n\n### Include Java Bindings in your Maven project\n\nFor versions \u003e= 2.0.0, add the following to your `pom.xml`:\n\n```xml\n\u003crepositories\u003e\n  \u003crepository\u003e\n      \u003cid\u003ejitpack.io\u003c/id\u003e\n      \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n  \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.detro\u003c/groupId\u003e\n    \u003cartifactId\u003eghostdriver\u003c/artifactId\u003e\n    \u003cversion\u003e2.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Include Java Bindings in your Gradle project\n\nJust add the following to your `build.gradle`:\n\n```gradle\nallprojects {\n  repositories {\n    maven { url 'https://jitpack.io' }\n  }\n}\n```\n\n```gradle\ndependencies {\n    ...\n    testCompile 'com.github.detro:ghostdriver:2.1.0'\n    ...\n}\n```\n\n### Alternative: how to use it via `RemoteWebDriver`\n\nLaunching PhantomJS in Remote WebDriver mode it's simple:\n```bash\n$ phantomjs --webdriver=PORT\n```\nOnce started, you can use any `RemoteWebDriver` implementation to send commands to it. I advice to take a look to the\n`/test` directory for examples.\n\n## F.A.Q.\n\n### What extra WebDriver `capabilities` GhostDriver offers?\n* **GhostDriver** extra Capabilities\n    * `phantomjs.page.settings.SETTING = VALUE` - Configure `page.settings`\n    on PhantomJS internal page objects (_windows_ in WebDriver context)\n    (see [reference](http://phantomjs.org/api/webpage/property/settings.html))\n    * `phantomjs.page.customHeaders.HEADER = VALUE` - Add extra HTTP Headers\n    when loading a URL\n    (see [reference](http://phantomjs.org/api/webpage/property/custom-headers.html))\n    * `phantomjs.page.whitelist` - an array of regex expressions of urls to accept. eg. ['my-awesome-website.com']\n    * `phantomjs.page.blacklist` - array of regex expressions of urls to ignore.  The blacklist overrides the whitelist. eg. ['google.com', 'github.com']\n    * `unhandledPromptBehavior` - set to `dismiss` to automatically dismiss\nall user prompts or set to `accept` to automatically accept all user prompts\n    * `loggingPrefs` - ghostdriver has two logs `browser` and `har`. The logs\ndefault to `\"OFF\"`.  follow the [DesiredCapabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities#loggingpreferences-json-object)\ndocumentation to enable the logs.\n* PhantomJSDriver **Java-binding** Capabilities\n    * `phantomjs.binary.path` - Specify path to PhantomJS executable to use\n    * `phantomjs.ghostdriver.path` - Specify path to GhostDriver `main/src.js`\n    script to use; allows to use a different version of GhostDriver then the one\n    embed in PhantomJS\n    * `phantomjs.cli.args` - Specify command line arguments to pass to the\n    PhantomJS executable\n    * `phantomjs.ghostdriver.cli.args` - Specify command line argument to pass to\n    GhostDriver (works only in tandem with `phantomjs.ghostdriver.path`)\n\n## Want to help? Read on!\n\nGhostDriver pushed the evolution of PhantomJS from the start. All the features required by PhantomJS to fit GhostDriver were designed to still feel \"consistent\" and \"at home\" with PhantomJS alone.\n\nTo drive that effort, I worked on a [PhantomJS fork](https://github.com/detro/phantomjs-ghostdriver), and then\npushed changes to PhantomJS master once agreed with the rest of the team on the changes.\n\nIf you are planning to contribute, that is the PhantomJS you should use.\n\n### Run validation tests\n\nHere I show how to clone this repo and kick start the (Java) tests. You need\n[Java SDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html)\nto run them.  ghostdriver requires Java 1.8.\n\n1. `git clone https://github.com/detro/ghostdriver.git`\n2. Configure `phantomjs_exec_path` inside `ghostdriver/test/config.ini` to point at the build of PhantomJS you just did\n3. `cd ghostdriver/test/java; ./gradlew test`\n\n#### Alternative: Run GhostDriver yourself and launch tests against that instance\n\n1. `phantomjs --webdriver=PORT`\n2. Configure `driver` inside `ghostdriver/test/config.ini` to point at the URL `http://localhost:PORT`\n3. `cd ghostdriver/test/java; ./gradlew test`\n\n### Project Directory Structure\n\nHere follows the output of the `tree -hd -L 3` command, trimmed of files and \"build directories\":\n\n```bash\n.\n├── [ 102]  binding\n│   └── [ 510]  java\n│       ├── [ 204]  build\n│       ├── [ 136]  gradle\n│       ├── [ 884]  jars            \u003c--- JARs containing Binding, related Source and related JavaDoc\n│       └── [ 102]  src             \u003c--- Java Binding Source\n├── [ 442]  src                     \u003c--- GhostDriver JavaScript core source\n│   ├── [ 306]  request_handlers    \u003c--- JavaScript \"classes/functions\" that handle HTTP Requests\n│   └── [ 204]  third_party         \u003c--- Third party/utility code\n│       └── [2.0K]  webdriver-atoms \u003c--- WebDriver Atoms, automatically imported from the Selenium project\n├── [ 204]  test\n│   ├── [ 476]  java                \u003c--- Java Tests\n│   │   ├── [ 136]  gradle\n│   │   ├── [ 136]  out\n│   │   └── [ 102]  src\n│   ├── [ 238]  python              \u003c--- Python Tests\n│   │   └── [ 102]  utils\n│   └── [ 340]  testcase-issue_240\n└── [ 238]  tools                   \u003c--- Tools (import/export)\n    └── [ 136]  atoms_build_dir\n\n20 directories\n```\n\n### WebDriver Atoms\n\nBeing GhostDriver a WebDriver implementation, it embeds the standard/default WebDriver Atoms to operate inside open\nwebpages. In the specific, the Atoms cover scenarios where the \"native\" PhantomJS `require('webpage')` don't stretch.\n\nDocumentation about how those work can be found [here](https://github.com/SeleniumHQ/selenium/wiki/Automation-Atoms)\nand [here](http://www.aosabook.org/en/selenium.html).\n\nHow are those Atoms making their way into GhostDriver? If you look inside the `/tools` directory you can find a bash\nscript: `/tools/import_atoms.sh`. That script accepts the path to a Selenium local repo, runs the\n[CrazyFunBuild](https://github.com/SeleniumHQ/selenium/wiki/Crazy-Fun-Build) to produce the compressed/minified Atoms,\ngrabs those and copies them over to the `/src/third_party/webdriver-atoms` directory.\n\nThe Atoms original source lives inside the Selenium repo in the subtree of `/javascript`. To understand how the build\nworks, you need to spend a bit of time reading about\n[CrazyFunBuild](https://github.com/SeleniumHQ/selenium/wiki/Crazy-Fun-Build): worth your time if you want to contribute to\nGhostDriver (or any WebDriver, as a matter of fact).\n\nOne thing it's important to mention, is that CrazyFunBuild relies on the content of `build.desc` file to understand\nwhat and how to build it. Those files define what exactly is built and what it depends on. In the case of the Atoms,\nthe word \"build\" means \"run Google Closure Compiler over a set of files and compress functions into Atoms\".\nThe definition of the Atoms that GhostDriver uses lives at `/tools/atoms_build_dir/build.desc`.\n\nLet's take this small portion of our `build.desc`:\n```\njs_library(name = \"deps\",\n  srcs = \"*.js\",\n  deps = [\"//javascript/atoms:deps\",\n          \"//javascript/webdriver/atoms:deps\"])\n\njs_fragment(name = \"get_element_from_cache\",\n  module = \"bot.inject.cache\",\n  function = \"bot.inject.cache.getElement\",\n  deps = [ \"//javascript/atoms:deps\" ])\n\njs_library(name = \"build_atoms\",\n  deps = [\n    ...\n    \"//javascript/webdriver/atoms:execute_script\",\n    ...\n  ]\n```\nThe first part (`js_library(name = \"deps\"...`) declares what are the dependency of this `build.desc`: with that CrazyFunBuild knows\nwhat to build before fulfilling our build.\n\nThe second part (`js_fragment(...`) defines an Atom: the `get_element_from_cache` is going to be the name of\nan Atom to build; it can be found in the module `bot.inject.cache` and is realised by the function named\n`bot.inject.cache.getElement`.\n\nThe third part (`js_library(name = \"build_atoms\"...`) is a list of the Atoms (either defined by something like the second\npart or in one of the files we declared as dependency) that we want to build.\n\nIf you reached this stage in understanding the Atoms, you are ready to go further by yourself.\n\n### Contributions and/or Bug Report\n\nYou can contribute by testing GhostDriver, reporting bugs and issues, or submitting Pull Requests.\nAny **help is welcome**, but bear in mind the following base principles:\n\n* Issue reporting requires a reproducible example, otherwise will most probably be **closed without warning**\n* Squash your commits by theme: I prefer a clean, readable log\n* Maintain consistency with the code-style you are surrounded by\n* If you are going to make a big, substantial change, let's discuss it first\n* I **HATE** CoffeeScript: assume I'm going to laugh off any \"contribution\" that contains such _aberrational crap_!\n* Open Source is NOT a democracy (and I mean it!)\n\n## License\nGhostDriver is distributed under [BSD License](http://www.opensource.org/licenses/BSD-2-Clause).\n\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdetro%2Fghostdriver.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdetro%2Fghostdriver?ref=badge_large)\n\n## Release names\nSee [here](http://en.wikipedia.org/wiki/List_of_ghosts).","funding_links":[],"categories":["Java","测试","I. Development"],"sub_categories":["2. Web development"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdetro%2Fghostdriver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdetro%2Fghostdriver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdetro%2Fghostdriver/lists"}