I've recently started using windmill and python to run automated tests of my web application. This is the python script that windmill auto-generated from recording my events:
# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient
import string
import random
def test_recordingSuite0():
client = WindmillTestClient(__name__)
client.click(id=u'input-999052296848829736')
client.type(text=u'btsr65ejdfgdjdfg', id=u'input-999052296848829736')
client.click(id=u'input-999052296848829736-1')
client.type(text=u'dfgdbdfgdfgjdfgjd', id=u'input-999052296848829736-1')
client.click(name=u'_u911175390904082714')
client.select(option=u'1', name=u'_u911175390904082714')
client.click(value=u'1')
client.click(id=u'input-497945674625883994')
client.type(text=u'dfgbhdfbgxcvbz3@asdfvsevsdf54.com', id=u'input-497945674625883994')
client.click(name=u'_u969737303932735624')
client.radio(name=u'_u969737303932735624')
client.type(text=u'asdg9a7e0g57wn4bgwsdfhsdfhsdfhssdhsd', id=u'input-542327653202413691')
#client.click(name=u'submit')
#client.waits.forPageLoad(timeout=u'20000')
I'm totally new to python and I'm working on learning some of the syntax right now. But can someone help me make the input-text random in the various fields?
For example: line 2: On one test I would like
client.type(text=u'LAKJSDOGUSDGSDGS', id=u'input-999052296848829736')
and on another:
client.type(text=u'908374098afsDGSGS', id=u'input-999052296848829736')
(random, different)
Thanks!
At the top of your program, you import the necessary modules and you get the list of characters that you want to put in your random strings:
import string
import random
CANDIDATE_CHARS = string.ascii_letters+string.digits # lowercase and uppercase letters, and digits
In the test function, you create a random string of alphanumeric characters, like so:
random_text = u''.join(random.choice(CANDIDATE_CHARS) for _ in range(16)) # 16 random characters
client.type(text=random_text, id=u'input-999052296848829736')