How to take multiple screenshots without overwriting?

I have a basic test case set up to test login and then capture a screenshot.

WebUI.setText(findTestObject(‘Login/Username’), username)

WebUI.setText(findTestObject(‘Login/Password’), password)

WebUI.click(findTestObject(‘Login/Login’))

WebUI.takeScreenshot(’/Users/Work/Pictures/test.png’)

This works as intended. However, I am feeding usernames and passwords from an internal database via a test suite so it runs 3 times trying 3 different combinations of usernames and passwords.

It saves every time but obviously, it overwrites. How can I make it save as a new name each time?

Is this what you want?

WebUI.takeScreenshot('/Users/Work/Pictures/test-' + username + '.png')

Perfect! Thank you!