Learn Selenium Python For Absolute Beginners Tutorial 25 (Writing To Files)

preview_player
Показать описание
In part twenty-five of the Selenium Python test automation for beginners series, Tim shows how you can use Python to write to files.

He introduces the open() function and the "w" write mode feature in Python to show how you can both create and write to a file (for example, txt, xls, etc).

He also shows how you can automically have Python close a file using the with-as statement and he concludes with showing how you can append data to your file using the "a" mode.

Please share your thoughts in the comments below!

Looking forward to hearing from you.

Check out TestDemy's FREE Course: How To Get Started In Software Testing With No Experience:

Рекомендации по теме
Комментарии
Автор

I was able to use an array to create testing checklists for multiple features at the same time. Here's what my code looked like:

items = [["Feature_1", 127], ["Feature_2", 253]]

for each in items:
with open("{}-Ref_{}.md".format(each[0], each[1]), "w") as f:
f.write("# Feature: {}".format(each[0]))
f.write("\n")
{ my actual checklists here }

This was great for writing out the testing requirements for each user story in a separate file, so I could easily test them as the work progressed.

pelargnium