Hello,
Is there any reference or could help me with my concern. So here, I created a custom keywords where I can reuse for my repeated test case which is to validate the values of the dropdown, and all of my test objects are dynamic or Parameterize Web Test Objects. My goal is I have one script in the custom keywords to validate the values of dropdown and it will call on my different test cases. My problem now is I don’t know how can I write my script.
This is my code now.
Custom keywords
@Keyword
def validateDdown (List list, String object) {
for (int count = 0 ; count<list.size(); count++) {
WebUI.verifyElementPresent(findTestObject('object'), 5)
System.out.println("Filter Field " + list.get(count) + " is diplayed")
}
}
Test Case
def validateWorkflowValues(){
WebUI.click(findTestObject('Test Ddown1/ddown_Workflow'))
CustomKeywords.'validateDropDown.validateDdown'(["Test 1","Test 2","Test 3"],findTestObject('Test and Ddown1/ddown_workFlowSelect',['selected']))
This is the xpath of my dropdown object:
(//div[contains(text(),‘${selected}’)])[1]
This is my original script before I switch it into custom keywords, and I have this 5 script into my test case just validate 5 dropdown.
Test Case 1: Workflow dropdown
/*List workfFlowList = [
“Test 1”,
“Test 2”,
“Test 3”
]
for (int i=0; i<workfFlowList.size(); i++) {
WebUI.verifyElementPresent(findTestObject('Test Object /ddown_workFlowSelect',[ 'selected' : workfFlowList.get(i)]), 5)
System.out.println("Filter Field " + workfFlowList.get(i) + " is diplayed")
}*/
Test Case 2 Type List Dropdown
List testTypeList = [
“Type List 1”,
“Type List 2”
]
WebUI.click(findTestObject('Test Typelist/ddown_TestType'))
for (int count=0; count<testTypeList.size(); count++) {
WebUI.verifyElementPresent(findTestObject('Test Typelist/ddown_testTypeSelect',[ 'selectTest' : testTypeList.get(count)]), 5)
System.out.println("Filter Field " + testTypeList.get(count) + " is diplayed")
}