Skip to content

pratikkabade/Web-Action-Recorder-Bookmarklet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Action Recorder Bookmarklet

This bookmarklet allows you to record your interactions on a webpage (clicks and other actions) and then generate a Python Selenium script to mimic those actions. It's a powerful tool for automating repetitive web tasks, creating test scripts, or simply documenting user flows.


Features

  • Record Clicks: Captures all your mouse clicks on interactive elements.
  • Track Actions: (You may want to elaborate on what "other actions" are here. For example: "Tracks form input, scrolling, and navigation.")
  • Generate Selenium Script: Automatically creates a runnable Python Selenium script to replay the recorded actions.
  • Bookmarklet Convenience: Easily activate the recording directly from your browser's bookmarks bar.

How to Use

1. Install the Bookmarklet

To install, simply drag the following link to your browser's bookmarks bar:

[Record Web Actions](javascript:(function(){/* Your bookmarklet code will go here */})())

Note: You'll need to replace /* Your bookmarklet code will go here */ with your actual JavaScript bookmarklet code.

2. Start Recording

  1. Navigate to the webpage where you want to record actions.
  2. Click on the "Record Web Actions" bookmarklet in your bookmarks bar.
  3. A recording indicator (e.g., a small floating icon, a console message) should appear, letting you know that recording has started.

3. Perform Actions

Interact with the webpage as you normally would. Click on buttons, fill out forms, navigate to different pages – all your actions will be tracked.

4. Stop Recording and Generate Script

  1. To stop recording, click the "Record Web Actions" bookmarklet again.
  2. Upon stopping, the generated Python Selenium script will be displayed. (You'll need to specify how it's displayed, e.g., in a new tab, a pop-up, or copied to the clipboard.)
    • Option 1 (Common): The script is copied to your clipboard, and a notification appears.
    • Option 2: A new tab opens displaying the script, allowing you to copy it.
    • Option 3: A downloadable .py file is generated.
  3. Copy the script and save it as a .py file (e.g., recorded_actions.py).

Running the Generated Selenium Script

To run the generated Python script, you'll need to have Python and the Selenium library installed.

Prerequisites:

  • Python 3.x: Download from python.org.
  • Selenium Library: Install via pip:
    pip install selenium
  • WebDriver: You'll need a WebDriver for your browser (e.g., ChromeDriver for Chrome, GeckoDriver for Firefox). Download it and ensure it's in your system's PATH or specify its location in your Python script.

Execution:

  1. Open your terminal or command prompt.
  2. Navigate to the directory where you saved your .py script.
  3. Run the script:
    python recorded_actions.py

The script will launch your browser and mimic the actions you recorded.


Customization and Development

How it Works (Briefly)

The bookmarklet injects JavaScript into the current page. This JavaScript listens for DOM events (like click, input, etc.), logs them, and stores relevant information (e.g., CSS selectors, text content). When recording stops, this logged data is then formatted into a Python Selenium script using pre-defined templates.

Potential Enhancements

  • More Action Types: Support for drag-and-drop, right-clicks, keyboard shortcuts.
  • Error Handling: Add more robust error handling to the generated Selenium scripts.
  • Conditional Logic: Allow users to insert simple conditional statements into their recorded flow.
  • Parameterization: Enable easy modification of input values in the generated script.
  • UI for Recording: A small, non-intrusive UI element on the page to start/stop recording and show status.

Troubleshooting

  • Script not generating: Ensure your bookmarklet code is correct and the browser's JavaScript console doesn't show any errors.
  • Selenium script failing:
    • Check if the WebDriver path is correct.
    • Verify that the elements (buttons, input fields) on the page haven't changed their structure (e.g., CSS classes, IDs) since recording. Webpages are dynamic!
    • Add time.sleep() statements in the generated script if elements are taking too long to load.
  • Bookmarklet not working: Some websites might have Content Security Policies (CSPs) that prevent bookmarklets from executing certain scripts.

Contributions

Feel free to suggest improvements or contribute to the development of this bookmarklet!


License

(Add your chosen license here, e.g., MIT, Apache 2.0, etc.)

About

This bookmarklet allows you to record your interactions on a webpage (clicks and other actions) and then generate a Python Selenium script to mimic those actions.

Topics

Resources

Stars

Watchers

Forks

Contributors