What things do you use scripting for?

Almost every thread I come across (here, Reddit, anywhere) where people ask about what tools people are using day to day for their testing role, a very frequently mentioned item is Python, “for scripting/automating small tasks”.

The problem for me is, no one ever elaborates on what those small tasks are. So that’s my question - if you’re using something like Python (or equivalent) to automate or otherwise help you in your everyday work, what exactly do you use it for?

5 Likes

You can check some of my articles with examples of how I’ve used Python scripting. It’s not about writing autotests or automation frameworks it’s more about using scripting/programming to automate particular actions, tasks, data generation, generate load and simulate some users’ actions, etc. And of course, data generation is an additional topic (but I don’t have an article with script examples on this topic) - I used Python to generate some random test data, for example by using an app’s API.

3 Likes

I am involved in testing software on hardware devices. These devices need to talk to each other and they are sending data over the ethernet to each other. So to test that I use python script to e.g, generate test data, to monitor the data or the message rate on the different channel, I use scripts to configure the devices, to update firmware or to monitor the CPU usage (e.g. performance tests). But I also use python scripts to query the JIRA API to check the list of tickets assigned to a certain release etc. …

2 Likes

Mostly I’ve used scripting for test data generation, I’d much rather spend a bit more time to script up something re-usable, than have to start from scratch each time + it constitutes to the Don’t Repeat Yourself (DRY) principle of software development.

Basically everything that takes longer then 2 minutes and is a repeated task.
For example (not all in Python):

  • Transferring Files from point A to point B for someone.
  • Grepping stuff out of a search
  • Validating files on a server after a deploy
  • Clearing folders
  • Running a certain file or scheduled Task

From: https://automatetheboringstuff.com/

  • Search for text in a file or across multiple files
  • Create, update, move, and rename files and folders
  • Search the Web and download online content
  • Update and format data in Excel spreadsheets of any size
  • Split, merge, watermark, and encrypt PDFs
  • Send reminder emails and text notifications
  • Fill out online forms
1 Like

I often use it to automatically extract data from systems like Jira or Jenkins via their respective APIs–or even to automate adding items to Jira. It can also be handy if you use text-based documentation–I was recently using the pylatex package to generate some appendices for a LaTeX document that depended on data exported from another system.

1 Like

creating JIRA bugs through API calls? I like the idea

Does using JS count?
I use JS scripts to automate certain forms and actions of the software I’m testing on.

1 Like

I haven’t used it for entering bugs, per se. More for stories or subtasks, particularly for stuff we know we need to do periodically or for every release.

Hi alex,
can we connect on some platform to discuss over testing software on hardware devices? I recently shifted to a project involving hardware and software interacting one another and i need to test it.
i have many questions regarding it :stuck_out_tongue:
let me know where we can connect. it would be a great help. thanks

glue
Scripting is a glue, to link things together tightly.
And to that end I’m doing things like grabbing settings from files, putting them into various apps via a commandline or doing the opposite to put settings into various files.
Basically moving data around, one of my favourite scripts when I worked at a large company was a small script that copied test result pass/ fail data out of the Jenkins CI and pushed it to a LED display panel. So there are some more exciting script use cases out there for sure.

My other boring but definitely main use-case for scripting is environment checks, where the script checks system package installation and state and networking connections to let me know a machine is not find it has missing modules or something. And by far the most boring use of scripts is to actually set machines up, boring because you really need it when you need it, but then you never use it for a few months until the next machine needs to be re-formatted again.

Scripting (for me) is best used when we have certainty, “I do this and it does that” style of testing. Basically we know what we want from something and want to confirm, or we want someone else to confirm it and want to give them a pre-defined path for how they get there.

It’s also good for sharing ways of working to others, like if we were doing UAT and want to tell people how a happy path works.

We created a repository for testing our project’s features. Here are the challenges and our solution:

Challenges:

  1. We use a .xlsx/.csv file to test a feature.
  2. We need to test how the page table grid responds when performing CRUD operations based on the current dataset volume.
  3. Team should have the file before testing, challenge being process was stagnant because we used the same file for our testing.

Solution:

We built a Python framework that:

  • Asks questions to generate a custom .csv file (e.g., number of sheets, rows, and records).
  • Allows us to create a file tailored to our testing needs for each release.

We enhanced the framework to cover dataset creation at table grid:

  • Ask for the base URL.
  • Build a payload where we need the dataset.
  • Determine the number of records and other metadata.
  • Use APIs to create the necessary datasets.

This approach ensures dynamic and tailored testing for different parts of our project.