{"id":18746832,"url":"https://github.com/michaelharper/node-js-browser-automation-simple-price-checker","last_synced_at":"2025-11-24T00:30:17.003Z","repository":{"id":79503606,"uuid":"188365023","full_name":"michaelharper/Node-JS-Browser-Automation-Simple-Price-Checker","owner":"michaelharper","description":"Behold, a simple price-checker thrown together using Node.js and Selenium/WebDriver.","archived":false,"fork":false,"pushed_at":"2019-05-24T08:18:58.000Z","size":145,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-12-28T20:46:13.481Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelharper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-05-24T06:27:37.000Z","updated_at":"2019-05-24T08:29:57.000Z","dependencies_parsed_at":"2023-03-27T23:33:44.812Z","dependency_job_id":null,"html_url":"https://github.com/michaelharper/Node-JS-Browser-Automation-Simple-Price-Checker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelharper%2FNode-JS-Browser-Automation-Simple-Price-Checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelharper%2FNode-JS-Browser-Automation-Simple-Price-Checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelharper%2FNode-JS-Browser-Automation-Simple-Price-Checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelharper%2FNode-JS-Browser-Automation-Simple-Price-Checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelharper","download_url":"https://codeload.github.com/michaelharper/Node-JS-Browser-Automation-Simple-Price-Checker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239629649,"owners_count":19671333,"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-11-07T16:27:08.766Z","updated_at":"2025-11-24T00:30:16.966Z","avatar_url":"https://github.com/michaelharper.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Browser Automation: Simple Price Checker with Node.js\nBehold, a simple price-checker thrown together using Node.js and Selenium/WebDriver.\n\nI've been interested in getting away from Selenium IDE for Firefox for some time and even though Selenium IDE can be extremely effective I needed to move into cross-browser testing. Browser testing aside, import.io has become mostly useless to me since implementing their 500 query/month limitation and I just don't feel like paying their usual prices for my frequency of use.\n\n![alt text](https://raw.githubusercontent.com/michaelharper/Browser-Automation-Simple-Price-Checker/master/images/pdp-screenshot.png \"PDP Screenshot\")\n\nThe below code will load MatterHackers' ColorFabb XT-CF20 Carbon Fiber Filament page and compare it to its standard price:\n\n```\nvar webdriver = require('selenium-webdriver'),\n  By = webdriver.By,\n  until = webdriver.until;\n\nvar driver = new webdriver.Builder()\n  .forBrowser('chrome')\n  .build();\n\ndriver.get('https://www.matterhackers.com/store/3d-printer-filament/colorfabb-xt-cf20-1.75mm');\ndriver.findElement(By.id('price')).getText().then(function(text) {\n  console.log('Current price is \\'' + text + '\\'');\n  var currentPrice = parseInt(text);\n  if (currentPrice \u003c 65.95) {\n    console.log('Discounted price, you should buy!');\n  }\n  if (currentPrice !== '') {\n    console.log('Test passed');\n  } else {\n    console.log('Test failed');\n  }\n});\n\ndriver.quit();\n```\n\n## Here are the invdividual steps:\n\n- The script loads selenium-webdriver for interaction with Chrome.\n- It then loads the builder() method boiler-plate.\n- WebDriver then gets the MatterHackers page.\n- It finds the price element by CSS id and extracts the text value.\n- Logs the price to my console (i.e. for me, my shell)\n- I convert the price string to an integer for the next step which is a conditional.\n- Compares the price to a fixed price variable which I defined before-hand.\n- If the price is less, console logs the message \"Discounted price, you should buy!\". This is probably where I will add an email notification of some sort.\n- I threw in standard test pass/fail output in case I wanted to get advanced and compare the results of this script across several days, weeks or months.\n- Finally, I exited Chrome.\n\nHere is the end result from my shell:\n\n![alt text](https://raw.githubusercontent.com/michaelharper/Browser-Automation-Simple-Price-Checker/master/images/terminal-screenshot.png \"Terminal Screenshot\")\n\nThis script can be automated with something like [Nightwatch.js](http://nightwatchjs.org/) or simply a cron tab. I'm considering adding in either an email notification as part of the conditional but I'm thinking it could be time to try out Twilio's free tier. :D\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelharper%2Fnode-js-browser-automation-simple-price-checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelharper%2Fnode-js-browser-automation-simple-price-checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelharper%2Fnode-js-browser-automation-simple-price-checker/lists"}