Hello folks,
How would I get a list of all text values from a dropdown.
For example on the ‘CURA Healthcare Service’ sample website the ‘Facility’ dropdown has 3 values:
‘Hongkong CURA Healthcare Center’, ‘Tokyo CURA Healthcare Center’ and 'Seoul CURA Healthcare Center.
I have tried using List and List but have not had luck yet.
I’ve done lots of searches but have not found any that have worked for me so far.
Does anyone have any resources they could point me to.
Imports:
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
Test Case:
WebUI.openBrowser(GlobalVariable.G_SiteURL)
WebUI.click(findTestObject('Page_CuraHomepage/btn_MakeAppointment'))
WebUI.waitForPageLoad(30)
WebUI.setText(findTestObject('00_makeAppointment/input_Username_username'), 'John Doe')
WebUI.click(findTestObject('00_makeAppointment/input_Demo account_form-control_1'))
WebUI.setText(findTestObject('00_makeAppointment/input_Password_password'), 'ThisIsNotAPassword')
WebUI.click(findTestObject('00_makeAppointment/button_Login'))
WebUI.selectOptionByValue(findTestObject('00_makeAppointment/select_TokyoCURAHealthcareCenter'), 'Hongkong CURA Healthcare Center', false)
WebUI.selectOptionByValue(findTestObject('00_makeAppointment/select_TokyoCURAHealthcareCenter'), 'Tokyo CURA Healthcare Center', false)
WebUI.selectOptionByValue(findTestObject('00_makeAppointment/select_TokyoCURAHealthcareCenter'), 'Seoul CURA Healthcare Center', false)
//I can create a manual list but would like to know how I can pull the list from the object:
List<String> status = ['Hongkong CURA Healthcare Center', 'Tokyo CURA Healthcare Center', 'Seoul CURA Healthcare Center']
WebUI.click(findTestObject('00_makeAppointment/select_TokyoCURAHealthcareCenter'))
for (int cnt = 0; cnt < status.size(); cnt++) {
WebUI.verifyElementPresent(findTestObject('00_makeAppointment/select_TokyoCURAHealthcareCenter', [('Status') : status.get(cnt)]), 5)
}