Search code examples
javascriptcontinuous-integrationautomated-teststest-framework

Automatically test local javascript library on production page


I would like to write an automatic test that goes on a production webpage which is using a specific library and replace it with the version I have on local.

This is useful for me to verify that when a new version of the library will be released to different pages they won't break (kind of smoke test).

For manual test atm I use Requestly to replace the host of the network request to that library, I'm wondering which would be the best test framework/approach to have an automatic test for that.


Solution

  • You can try the following approach:

    Upload/Share your rules to get a URL

    1. Create Requestly Rule which you need in production and share it using Requestly Share Rules feature. Once you share the rules, you will get a URL (say X). You can use the url to import the same rules at any other device.

    Use Selenium to install Requestly

    1. Use Selenium to open Chrome Browser, Install Requestly from Chrome Store.
    2. Open https://app.requestly.in/rules/ in a tab via Selenium script

    Load the Rules

    1. Open url X (Obtained in Step 1) and use selenium script to click on "Import List" button.

    Run Automation Tests

    1. Now, you have the rules in your chrome. Use the same selenium session to run your automation tests.

    Please note that you have to repeat Steps 1-4 everytime you open a new chrome instance using Selenium (or any other framework). It may increase your automation suite running time a bit but atleast it achieves what you want.