{"id":22678353,"url":"https://github.com/evilc/aliexpresslogindemo","last_synced_at":"2025-03-29T13:12:26.763Z","repository":{"id":247660009,"uuid":"826487827","full_name":"evilC/AliExpressLoginDemo","owner":"evilC","description":"A demo of an app that can log in to AliExpress","archived":false,"fork":false,"pushed_at":"2024-07-09T20:02:49.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-04T13:44:38.458Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/evilC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-09T19:57:54.000Z","updated_at":"2024-07-09T20:02:52.000Z","dependencies_parsed_at":"2024-07-10T00:35:51.159Z","dependency_job_id":"8d9b9c4a-ef46-46b8-a725-1a3eea2f8aae","html_url":"https://github.com/evilC/AliExpressLoginDemo","commit_stats":null,"previous_names":["evilc/aliexpresslogindemo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilC%2FAliExpressLoginDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilC%2FAliExpressLoginDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilC%2FAliExpressLoginDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilC%2FAliExpressLoginDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evilC","download_url":"https://codeload.github.com/evilC/AliExpressLoginDemo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246187242,"owners_count":20737462,"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-12-09T18:14:53.984Z","updated_at":"2025-03-29T13:12:26.737Z","avatar_url":"https://github.com/evilC.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AliExpressLoginDemo\n\n A demo of an app that can log in to AliExpress\n\n## Goal\n\n1. Learn some Java\n\n2. Write a POC for an app which can automate AliExpress\n\n## Problem\n\nWhile working on a GUI app (Using Java Swing) I was trying to write, I discovered that when you open a browser using Selenium, when you go to log in, you get a CAPTCHA slider.\n\nEven if you manually drag the slider (As a human), it will not let you log in.\n\n## Solution\n\n1. Execute the Chrome binary directly (eg using `chrome.exe --remote-debugging-port=9222 --user-data-dir=remote-profile`)\n\n2. Prompt the user to log into this browser\n\n3. Connect to this Chrome instance using Selenium once the user has logged in\n\n4. Dump the cookies to a JSON file (See the `CookieJar` class - I can't believe I could not find something like this through searches. Lots of over-complicated examples trying to serialize the data themselves!)\n\nThen, the app is \"Set up\".\n\nWe can then open a normal Selenium webdriver instance without calling the Chrome binary directly and load in the cookies, thus logging you in. Hell, this new instance *does not even need to be Chrome* - Firefox works ;)\n\n## What else I tried\n\nI tried pointing the non-DevTools browser instance to the same user-data-dir but I was getting an error saying `Could not remove old devtools port file. Perhaps the given user-data-dir at is still attached to a running Chrome or Chromium process`. I could not resolve it, so dumping and loading Cookies was the only way I could get it to work\n\n## Credits\n\nI am a total Java noob. I also haven't done much with Cookies or logging in (Or even browser automation really), so I did a *lot* of Googling\n\n* [This SO post](https://stackoverflow.com/questions/8344776/can-selenium-interact-with-an-existing-browser-session)  was the start of the light at the end of the tunnel for me\n\n* [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) made things a lot cleaner. I was really struggling with getting Chrome working in Selenium, and this makes it super simple. As an added bonus, it also removes the need for the end-user (I plan on distributing my app to friends if I get it working) to have to download ChromeDriver and stuff. Furthermore, it provides a getter to get the location of the Chrome executable, so I could call it to launch the DevTools instance, and not need any settings file or anything to store that.\n\n\n\n## Notes\n\nWebDriverManager is one of the main reasons for this repo. Initially I was having a problem with it being really slow to launch the browser instance, so I made a GUI app to demonstrate the issue, planning on posting it on their support forum, but then, magically, it started working just fine. Still no idea why.\n\nOh well, may as well package it up, hopefully it will serve as a useful example to someone else - I certainly could not find complete examples of doing this kind of thing, so hopefully it helps someone, somewhere.\n\nI did mention I was a total Java noob, right? Fair warning - there's no error handling, probably janky code all over the shop - you have been warned.\n\nIf you know any better, I would welcome a PR.\n\n\n\n## Usage\n\n1. Launch the app\n\n2. Click `Login with DevTools Chrome`\n   The first time you do this, it will be like you just installed a fresh copy of Chrome (Setup page and all) - it's your normal Chrome instance, but seeing as I specified `--user-data-dir` as well as enabled the remote debugger, it's using a new profile.\n   This is stored in `BrowserProfile` in the app's folder.\n   This seemed like a sensible move, as then this app shouldn't have access to all your other cookies I guess?\n\n3. Follow the instructions in the app's dialog (ie log in)\n\n4. Click OK in the app's dialog\n\n5. The cookies will be saved to `Cookies.json` and the DevTools Chrome instance will automatically close\n\n6. You can now click `Open Chrome` or `Open Firefox` to open a \"normal\" Selenium browser\n\n7. After that, the `Navigate to checkout`demonstrates automation of the currently open browser while logged in\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilc%2Faliexpresslogindemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevilc%2Faliexpresslogindemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilc%2Faliexpresslogindemo/lists"}