{"id":15020900,"url":"https://github.com/mike10004/selenium-capture","last_synced_at":"2025-10-26T16:30:48.549Z","repository":{"id":39962329,"uuid":"74161453","full_name":"mike10004/selenium-capture","owner":"mike10004","description":"Browse with Selenium in Java and capture your traffic in a HAR file.","archived":false,"fork":false,"pushed_at":"2022-11-16T09:27:30.000Z","size":935,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T21:11:27.881Z","etag":null,"topics":["chrome-webdriver","firefox-webdriver","java","selenium","webdriver"],"latest_commit_sha":null,"homepage":"","language":"Java","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/mike10004.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-18T19:49:13.000Z","updated_at":"2023-05-04T05:52:05.000Z","dependencies_parsed_at":"2022-09-09T09:31:03.398Z","dependency_job_id":null,"html_url":"https://github.com/mike10004/selenium-capture","commit_stats":null,"previous_names":["mike10004/selenium-help"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike10004%2Fselenium-capture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike10004%2Fselenium-capture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike10004%2Fselenium-capture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike10004%2Fselenium-capture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mike10004","download_url":"https://codeload.github.com/mike10004/selenium-capture/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238366692,"owners_count":19460170,"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":["chrome-webdriver","firefox-webdriver","java","selenium","webdriver"],"created_at":"2024-09-24T19:55:49.612Z","updated_at":"2025-10-26T16:30:43.103Z","avatar_url":"https://github.com/mike10004.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Travis build Status](https://travis-ci.org/mike10004/selenium-capture.svg?branch=master)](https://travis-ci.org/mike10004/selenium-capture)\n[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/fuk4sjvhjl66or7f?svg=true)](https://ci.appveyor.com/project/mike10004/selenium-capture)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.mike10004/selenium-capture.svg)](https://repo1.maven.org/maven2/com/github/mike10004/selenium-capture/)\n\nselenium-capture\n=============\n\nThis is a library that facilitates capturing HTTP traffic from a Selenium \nweb-browsing session. An intercepting proxy is used to capture the traffic.\n\nExample\n-------\n\n    // be sure to define system property with geckodriver location if not contained in $PATH\n    // System.setProperty(\"webdriver.gecko.driver\", \"/path/to/geckodriver\");\n    FirefoxWebDriverFactory factory = FirefoxWebDriverFactory.builder()\n            .configure(firefoxOptions -\u003e {\n                firefoxOptions.setAcceptInsecureCerts(true);\n            })\n            .build();\n    Path scratchDir = java.nio.file.Files.createTempDirectory(\"selenium-capture-example\");\n    try {\n        TrafficCollector collector = TrafficCollector.builder(factory)\n                .collectHttps(new AutoCertificateAndKeySource(scratchDir))\n                .build();\n        HarPlus\u003cString\u003e harPlus = collector.collect(new TrafficGenerator\u003cString\u003e() {\n            @Override\n            public String generate(WebDriver driver) {\n                driver.get(\"https://www.example.com/\");\n                return driver.getTitle();\n            }\n        });\n        System.out.println(\"collected page with title \" + harPlus.result);\n        File harFile = File.createTempFile(\"selenium-capture-example\", \".har\");\n        BrowserUpHars.writeHar(harPlus.har, harFile, StandardCharsets.UTF_8);\n        System.out.format(\"%s contains captured traffic%n\", harFile);\n    } finally {\n        FileUtils.forceDelete(scratchDir.toFile());\n    }\n\nCapturing HTTPS traffic\n-----------------------\n\nTo capture HTTPS traffic, the proxy must MITM the TLS traffic and the browser \nmust be configured to trust the proxy's certificate or to accept insecure \ncertificates. \n\nThe library will generate a self-signed certificate on demand to capture HTTPS\ntraffic, or you can pre-generate one (take a look at the \n[GenerateNewCertificate][generate-new] class in the test sources).\n\nGenerating a new certificate takes up to 1000ms, so if you're frequently \ngenerating new certificates with the auto-generator, then you might save time \nby pre-generating a certificate and reusing it. For some examples of reusing \na pre-generated certificate, take a look at the unit tests where HTTPS traffic \nis captured.\n\nProviding cookies to your browser\n---------------------------------\n\nThe WebDriver APIs for cookie management are a tad simplistic. They have \nannoying snafus like \n\n* you can't add cookies associated with a site whose page is not open in the \n  browser window, \n* you can't add cookies with all of the attributes the browser is capable of\n  storing\n* you can't export cookies with all of the original attributes like expiration\n  date\n\nThis library helps resolve the first two of these snafus for Firefox by \nproviding a mechanism to generate the SQLite database where the browser stores \ncookies in the user profile directory.\n\nTo resolve the issue of cookie export, you can use the traffic capture to \ngain access to all cookies that were sent during a browsing session.\n\nRequired Driver Versions\n------------------------\n\nMake sure to keep your [Chromedriver][chromedriver-downloads] and \n[Geckodriver][geckodriver-releases] installations up to date. When \n[Selenium][selenium-releases] gets updated, the minimum required versions \nof the driver executables are often raised. \n\n[geckodriver-releases]: https://github.com/mozilla/geckodriver/releases\n[chromedriver-downloads]: https://sites.google.com/a/chromium.org/chromedriver/downloads\n[selenium-releases]: https://github.com/SeleniumHQ/selenium/releases","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmike10004%2Fselenium-capture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmike10004%2Fselenium-capture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmike10004%2Fselenium-capture/lists"}