I Have function register a patient that will Return Medical record Number , Need store this as Global Variable to so that use the same for Different Functions Eg: Create Vital Sign , Create Lab Order etc.
aqTestCase.Begin(" User able to Register a Unknown patient")
Log.AppendFolder("Unknown Registeration Logs")
ERPage=Aliases.MedBrowser.pageER
ReusableFunctions.ClickonObject(ERPage.RegisterUnknownPatientIcon)
ReusableFunctions.ClickonObject(ERPage.UnknownRegMaleLabel)
ReusableFunctions.setTextValue(ERPage.txtAge, "20")
ReusableFunctions.ClickonObject(ERPage.UnknownRegregistrBtn)
ReusableFunctions.ClickonButton(ERPage.AssignBuutonclose)
AppReusableFunctions.getToastMsgs(ERPage)
labelER = Aliases.VidaPlusBrowser.pageER.FindElement("//span[.='ER']")
ReusableFunctions.ClickonObject(labelER)
mrn = ERPage.FindElement("//div[10]/div[5]/app-er-patient-grid-mrn/span").contentText
aqUtils.Delay(2000)
ReusableFunctions.ClickonObject(ERPage.ERArrvialTime)
Log.Message(" Unknown Patient Registred MRN is : " mrn)
return mrn
CodePudding user response:
You can set the variable as a global variable and return it.
def foo():
global X
X = 1
return X
In your case, creating a class may work better.
class Foo:
def __init__(self, x):
self.x = x
def bar(self):
return self.x
f = Foo(1)
f.bar()
CodePudding user response:
x = "awesome"
def myfunc():
global x
x = "fantastic"
myfunc()
print("Python is " x)