How We Use ChatGPT in Consultancy: A Blog Series Preview
In this series, I will walk you through hands-on demonstrations of how we leverage ChatGPT in our daily consultancy activities.
Today I was talking to a Tosca expert(very hard working guy though) and we were talking about how long it would take to parse a xml data set to generate a bsn structure for a certain activity for one projects. I gave him the challenge to do it totally different and he choose for python
The Big Question:
So the question was: Can ChatGPT work together helping him creating a python script by a tester who does not have any programming skills? :sweat_smile: The answer is… yes ;-),but :rocket: :woman_technologist: :man_technologist:
Yes, ChatGPT can indeed assist in crafting a Python script even for a tester who lacks programming expertise. :smiley: However, there are certain nuances and complexities in scripting that might require a deeper dive or some hands-on practice to fully getting hold on it. But with the right guidance anything is possible!
The first thing I advised him to do is installing faker
Start by installing
Faker, a library that can generate mock data in various languages. This will be handy for populating our XML structure.
pip install Faker
Crafting the Script:
To structure the XML, use
This can generate mock data for any language which can be used in the xml structure to be created. Second import which Chatgpt gave us and I never heard of (the above one I did) is ET.Element. This actually setups a an elementree object for xml and you can then enter data based on the tag structure
from faker import Faker import xml.etree.ElementTree as ET fake = Faker('nl_NL') # Dutch locale def generate_dutch_citizen_data(): citizen = ET.Element("citizen") # First name and last name name = ET.SubElement(citizen, "name") name.text = fake.name() # BSN bsn = ET.SubElement(citizen, "bsn") bsn.text = fake.ssn() # In the Dutch locale, ssn() generates a BSN. return citizen def main(): root = ET.Element("citizens") # Generate data for 10 citizens for _ in range(10): citizen = generate_dutch_citizen_data() root.append(citizen) # Convert the XML data to a string and save tree = ET.ElementTree(root) tree.write("dutch_citizens_data.xml") if __name__ == "__main__": main()
When the script has be made and you have ran the script locally you can see that it created a structure.
<citizens> <citizen> <name>Full Name of Citizen 1</name> <bsn>BSN of Citizen 1</bsn> </citizen> <citizen> <name>Full Name of Citizen 2</name> <bsn>BSN of Citizen 2</bsn> </citizen> ... <citizen> <name>Full Name of Citizen 10</name> <bsn>BSN of Citizen 10</bsn> </citizen> </citizens>
Caviats are: you still need to have some programming skills. It is nice that Chatgpt generates code and does suggestions but still you have to interpret if the code is efficient and working. So for a nontechnical tester. Dive into the studybooks and learn!
More things which can be done with ChatGPT are:
Creating Test Cases: ChatGPT can help make test cases for your software. If you tell it what a user does on a website, it can think of different situations to test. Like, what happens if the password is wrong? Or if a user tries to log in too many times?
Writing Test Documents: Need to write down how you tested? Or the results? ChatGPT can help you write these documents.
Exploring Software: ChatGPT can help testers look around the software to find mistakes by talking to it.
Guessing Where Bugs Are: ChatGPT can try to guess where the software might have problems. This helps testers know where to look first.
Helping Teams Talk: Sometimes it’s hard for people who know a lot about technology to talk to people who don’t. ChatGPT can help them understand each other by turning what they say into test steps.
This is just the start. There’s a lot more we can do with AI in testing and I believe it has a lot of potential
More information on how to create this example Pythonfile can be found in my repo
Follow me on LinkedIn: www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=ralphvanderhorst if you have any questions