I'm using WebDriiver, lettuce and python for testing. In first scenario I verifay, that user can create anaccount. For user name I use an e-mail generaror with timestamp. the lettuce step is:
Then input text "NEW_EMAIL" to text field with ID "s-txt-email"
the python code is:
@step('input text "([^"]*)" to text field with ID "([^"]*)"')
def input_with_id(step, txt, ID):
global new_email
links = get_driver().find_elements_by_xpath("//input[@id='%s']" % ID)
if links:
links[0].click()
else:
raise ValueError('Link with ID %s not found' % ID)
if not "generated_email" in txt:
timestamp = datetime.now().strftime('%m_%d_%Y.%H_%M')
new_email = "automation.%s@yopmail.com" % timestamp
txts = {"NEW_EMAIL": new_email,
"STANDARD_PSW": "xxxxx",
"NEW_USER": new_email,
}
if txt in txts.keys():
txt = txts[txt]
else:
txt = new_email
links[0].send_keys(str(txt))
In other scenario I'm using the same code for verify that user can loggin. Lettuce step is:
Then input text "generated_email" to text field with ID "l-txt-email-address"
And python code is the same (see above). But it's generated new e-mail with new timestamp and user can't loggin. What I'm douing wrong? How I can use global variable from one scenario in other one?
Aucun commentaire:
Enregistrer un commentaire