mercredi 15 avril 2015

Generate random value once for every issue Python

I'm trying to generate random title for an auction and then use it outside the method.


add_consignment.py:



class AddConsignmentPage(BasePage):
_title_uuid = get_random_uuid(7)

def new_furniture_consignment(self):
AddConsignmentPage._title_uuid = get_random_uuid(7) #generate new title each time method starts
self.send_keys(self._title_uuid, self._consignment_title)


and I want to use the same _title_uuid to view added consignment (type it's title into search field) view_consignments.py



class ViewConsignmentsPage(BasePage):
_title_uuid = AddConsignmentPage._title_uuid

def check_added_consignment(self):
self.send_keys(self._title_uuid, self._auction_search)


In this scenario the title is generated two times (second and 5th line) so title in added consignment is different than title in search field


If I delete the fifth line every added consignment has the same title


Second line has to be there to read it from view_consignments.py


How to get it generated once for every consignment?





Aucun commentaire:

Enregistrer un commentaire