I created a Keyword to store the data that I will use to validate.
@Keyword
def storeDatas() {
String doctor = WebUI.getText(findTestObject('Relatorio Atual/Name_Doctor'))
String utente = WebUI.getText(findTestObject('Relatorio Atual/Name_Utente'))
String snsWithDate = WebUI.getText(findTestObject('Relatorio Atual/Sns_Bithdate'))
}
Now I need to use these variables in my test case in verifyElementText command, how I can use it?
WebUI.verifyElementText(findTestObject(‘Relatorio Atual/Name_Doctor’), )
Do you really need a keyword for this? The only reason to do this would be if you want to perform this exact same task across different test cases.
Assuming that you indeed want to wrap this in a keyword, then you will need to return a list containing all three strings:
@Keyword
public List<String> getData() {
List<String> data = new ArrayList<String>();
data.add(WebUI.getText(findTestObject('Relatorio Atual/Name_Doctor')));
data.add(WebUI.getText(findTestObject('Relatorio Atual/Name_Utente')));
data.add(WebUI.getText(findTestObject('Relatorio Atual/Sns_Bithdate')));
return data;
}
Hi @Brandon_Hein,
Thank you for your help, yes I need this in Keyword because I will use in various test cases.
Ok so I use an array to store the data but how I use this in the test case?
I thought in this but doesn’ work.
WebUI.verifyElementText(findTestObject('Teleconsulta/Name_Doctor'), getData.data[0])
It’s not an array, it’s a list, so you would access members of that list using get():
List<String> data = new MyKeyword().getData();
WebUI.verifyElementText(findTestObject('Teleconsulta/Name_Doctor'), data.get(0));
Thank you for your help.
so this way worked for me.
Keyword
public List<String> getData() { List<String> data = new ArrayList<String>(); data.add(WebUI.getText(findTestObject('Teleconsulta/Name_Doctor'))); data.add(WebUI.getText(findTestObject('Teleconsulta/Name_Utente'))); data.add(WebUI.getText(findTestObject('Teleconsulta/Sns_Bithdate'))); return data; }
And using into the test case:
WebUI.verifyElementText(findTestObject('Relatorio Atual/data_Teleconsulta'), CustomKeywords.'live.Live.getData'().get(0));