@@ -180,30 +180,32 @@ function addSchedule() {
180180 // Open add schedule form
181181 selectConfigMenu ( addScheduleConfigOption ) ;
182182 // Checks if Save button is disabled initially
183- cy . getFormFooterButtonByType ( saveButton , 'submit' ) . should (
184- 'be.disabled'
185- ) ;
183+ cy . getFormFooterButtonByType ( saveButton , 'submit' ) . should ( 'be.disabled' ) ;
186184 // Adding data
187185 cy . getFormInputFieldById ( nameInputFieldId ) . type ( initialScheduleName ) ;
188186 cy . getFormInputFieldById ( descriptionInputFieldId ) . type ( initialDescription ) ;
189187 cy . getFormInputFieldById ( activeCheckboxFieldId , 'checkbox' ) . check ( {
190188 force : true ,
191189 } ) ;
192190 // Select Action type option: 'VM Analysis'
193- cy . get ( 'select#action_typ' ) . select ( actionTypeVmAnalysis ) ;
191+ cy . getFormSelectFieldById ( actionTypeSelectFieldId ) . select (
192+ actionTypeVmAnalysis
193+ ) ;
194194 // Select Filter type option: 'A Single VM'
195- cy . get ( 'select#filter_typ' ) . select ( actionTypeVmAnalysis ) ;
195+ cy . getFormSelectFieldById ( filterTypeSelectFieldId ) . select (
196+ actionTypeVmAnalysis
197+ ) ;
196198 // Select Run option: 'Hours'
197- cy . get ( 'select#timer_typ' ) . select ( timerTypeHourly ) ;
199+ cy . getFormSelectFieldById ( timerTypeSelectFieldId ) . select ( timerTypeHourly ) ;
198200 // Select Every option: '1 Hour'
199- cy . get ( 'select#timer_value' ) . select ( frequencyTypeHour ) ;
201+ cy . getFormSelectFieldById ( timerValueSelectFieldId ) . select ( frequencyTypeHour ) ;
200202 // Select Time zone option: '(GMT-10:00) Hawaii'
201- cy . get ( 'input[role="combobox"]#time_zone' ) . click ( ) ;
203+ cy . getFormInputFieldById ( timeZoneInputFieldId ) . click ( ) ;
202204 cy . contains ( '[role="option"]' , timezoneTypeHawaii )
203205 . should ( 'be.visible' )
204206 . click ( ) ;
205- cy . get ( 'input#start_date' ) . type ( initialStartDate ) ;
206- cy . get ( 'input#start_time' ) . type ( startTime ) ;
207+ cy . getFormInputFieldById ( startDateInputFieldId ) . type ( initialStartDate ) ;
208+ cy . getFormInputFieldById ( startTimeInputFieldId ) . type ( startTime ) ;
207209 // Intercepting the API call for adding a new schedule
208210 cy . interceptApi ( {
209211 alias : 'addScheduleApi' ,
@@ -275,33 +277,33 @@ function invokeCleanupDeletion() {
275277}
276278
277279function selectAndAssertDropdownValue ( id , value ) {
278- cy . get ( `select# ${ id } ` ) . select ( value ) ;
279- cy . get ( `select# ${ id } ` ) . should ( 'have.value' , value ) ;
280+ cy . getFormSelectFieldById ( id ) . select ( value ) ;
281+ cy . getFormSelectFieldById ( id ) . should ( 'have.value' , value ) ;
280282}
281283
282284function assertSelectFieldWithLabel ( id ) {
283- cy . get ( `label[for=" ${ id } "]` ) . should ( 'exist' ) ;
284- cy . get ( `select# ${ id } ` ) . should ( 'exist' ) ;
285+ cy . getFormLabelByInputId ( id ) . should ( 'exist' ) ;
286+ cy . getFormSelectFieldById ( id ) . should ( 'exist' ) ;
285287}
286288
287289function selectActionTypeAndAssertFilterTypeDropdown ( value ) {
288- selectAndAssertDropdownValue ( 'action_typ' , value ) ;
289- assertSelectFieldWithLabel ( 'filter_typ' ) ;
290+ selectAndAssertDropdownValue ( actionTypeSelectFieldId , value ) ;
291+ assertSelectFieldWithLabel ( filterTypeSelectFieldId ) ;
290292}
291293
292294function selectTimerTypeAndAssertTimerDropdown ( value ) {
293- selectAndAssertDropdownValue ( 'timer_typ' , value ) ;
294- assertSelectFieldWithLabel ( 'timer_value' ) ;
295+ selectAndAssertDropdownValue ( timerTypeSelectFieldId , value ) ;
296+ assertSelectFieldWithLabel ( timerValueSelectFieldId ) ;
295297}
296298
297299function assertComboboxWithLabel ( id ) {
298- cy . get ( `label[for=" ${ id } "]` ) . should ( 'exist' ) ;
299- cy . get ( `input[role="combobox"]# ${ id } ` ) . should ( 'exist' ) ;
300+ cy . getFormLabelByInputId ( id ) . should ( 'exist' ) ;
301+ cy . getFormInputFieldById ( id ) . should ( 'exist' ) ;
300302}
301303
302304function assertInputFieldWithLabel ( id ) {
303- cy . get ( `label[for=" ${ id } "]` ) . should ( 'exist' ) ;
304- cy . get ( `input# ${ id } ` ) . should ( 'exist' ) ;
305+ cy . getFormLabelByInputId ( id ) . should ( 'exist' ) ;
306+ cy . getFormInputFieldById ( id ) . should ( 'exist' ) ;
305307}
306308
307309describe ( 'Automate Schedule form operations: Settings > Application Settings > Settings > Schedules > Configuration > Add a new schedule' , ( ) => {
@@ -350,46 +352,49 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
350352
351353 /* ===== Selecting "Automation Tasks" option from "Action" dropdown shows Zone, Object details & Object fields ===== */
352354
353- selectAndAssertDropdownValue ( 'action_typ' , actionTypeAutomationTasks ) ;
355+ selectAndAssertDropdownValue (
356+ actionTypeSelectFieldId ,
357+ actionTypeAutomationTasks
358+ ) ;
354359
355360 // Checking for Zone dropdown
356- assertSelectFieldWithLabel ( 'zone_id' ) ;
361+ assertSelectFieldWithLabel ( zoneSelectFieldId ) ;
357362
358363 // Checking for Object Details
359364 cy . get ( 'h3[name="object_details"]' ) . should ( 'exist' ) ;
360365 // Checking for System/Process dropdown
361- assertSelectFieldWithLabel ( 'instance_name' ) ;
366+ assertSelectFieldWithLabel ( systemSelectFieldId ) ;
362367 // Checking for Messsage textfield
363- assertInputFieldWithLabel ( 'message' ) ;
368+ assertInputFieldWithLabel ( messageInputFieldId ) ;
364369 // Checking for Request textfield
365- assertInputFieldWithLabel ( 'request' ) ;
370+ assertInputFieldWithLabel ( requestInputFieldId ) ;
366371
367372 // Checking for Object
368373 cy . get ( 'h3[name="object_attributes"]' ) . should ( 'exist' ) ;
369374 // Checking for Type Combobox
370- assertComboboxWithLabel ( 'target_class' ) ;
375+ assertComboboxWithLabel ( typeInputFieldId ) ;
371376 // Checking for Object Combobox
372- assertComboboxWithLabel ( 'target_id' ) ;
377+ assertComboboxWithLabel ( objectInputFieldId ) ;
373378
374379 // Checking for Attribute/Value pairs
375380 cy . contains ( 'h3' , 'Attribute/Value Pairs' ) . should ( 'exist' ) ;
376381 // Checking for 5 attribute-value pairs text fields
377- cy . get ( 'input# attribute_1') . should ( 'exist' ) ;
378- cy . get ( 'input# value_1') . should ( 'exist' ) ;
379- cy . get ( 'input# attribute_2') . should ( 'exist' ) ;
380- cy . get ( 'input# value_2') . should ( 'exist' ) ;
381- cy . get ( 'input# attribute_3') . should ( 'exist' ) ;
382- cy . get ( 'input# value_3') . should ( 'exist' ) ;
383- cy . get ( 'input# attribute_4') . should ( 'exist' ) ;
384- cy . get ( 'input# value_4') . should ( 'exist' ) ;
385- cy . get ( 'input# attribute_5') . should ( 'exist' ) ;
386- cy . get ( 'input# value_5') . should ( 'exist' ) ;
382+ cy . getFormInputFieldById ( ' attribute_1') . should ( 'exist' ) ;
383+ cy . getFormInputFieldById ( ' value_1') . should ( 'exist' ) ;
384+ cy . getFormInputFieldById ( ' attribute_2') . should ( 'exist' ) ;
385+ cy . getFormInputFieldById ( ' value_2') . should ( 'exist' ) ;
386+ cy . getFormInputFieldById ( ' attribute_3') . should ( 'exist' ) ;
387+ cy . getFormInputFieldById ( ' value_3') . should ( 'exist' ) ;
388+ cy . getFormInputFieldById ( ' attribute_4') . should ( 'exist' ) ;
389+ cy . getFormInputFieldById ( ' value_4') . should ( 'exist' ) ;
390+ cy . getFormInputFieldById ( ' attribute_5') . should ( 'exist' ) ;
391+ cy . getFormInputFieldById ( ' value_5') . should ( 'exist' ) ;
387392
388393 /* ===== Selecting "Once" option from "Run" dropdown does not show the "Every" dropdown ===== */
389394
390- selectAndAssertDropdownValue ( 'timer_typ' , timerTypeOnce ) ;
395+ selectAndAssertDropdownValue ( timerTypeSelectFieldId , timerTypeOnce ) ;
391396 // Checking whether the Every dropdown is hidden
392- cy . get ( 'input#timer_value' ) . should ( 'not.exist' ) ;
397+ cy . getFormInputFieldById ( timerValueSelectFieldId ) . should ( 'not.exist' ) ;
393398
394399 /* ===== Selecting any other option other than "Once" from "Run" dropdown shows the "Every" dropdown ===== */
395400 // Selecting "Hourly" to verify timer dropdown
@@ -421,8 +426,10 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
421426 // Open edit schedule form
422427 selectConfigMenu ( editScheduleConfigOption ) ;
423428 // Editing name and description
424- cy . get ( 'input#name' ) . clear ( ) . type ( editedScheduleName ) ;
425- cy . get ( 'input#description' ) . clear ( ) . type ( editedDescription ) ;
429+ cy . getFormInputFieldById ( nameInputFieldId ) . clear ( ) . type ( editedScheduleName ) ;
430+ cy . getFormInputFieldById ( descriptionInputFieldId )
431+ . clear ( )
432+ . type ( editedDescription ) ;
426433 // Confirms Save button is enabled after making edits
427434 cy . getFormFooterButtonByType ( saveButton , 'submit' )
428435 . should ( 'be.enabled' )
@@ -442,14 +449,24 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
442449 // Open edit schedule form
443450 selectConfigMenu ( editScheduleConfigOption ) ;
444451 // Editing description and start date
445- cy . get ( 'input#description' ) . clear ( ) . type ( editedDescription ) ;
446- cy . get ( 'input#start_date' ) . clear ( ) . type ( editedStartDate ) ;
452+ cy . getFormInputFieldById ( descriptionInputFieldId )
453+ . clear ( )
454+ . type ( editedDescription ) ;
455+ cy . getFormInputFieldById ( startDateInputFieldId )
456+ . clear ( )
457+ . type ( editedStartDate ) ;
447458 // Resetting
448459 cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.enabled' ) . click ( ) ;
449460 cy . expect_flash ( flashClassMap . warning , flashMessageResetSchedule ) ;
450461 // Confirming the edited fields contain the old values after resetting
451- cy . get ( 'input#description' ) . should ( 'have.value' , initialDescription ) ;
452- cy . get ( 'input#start_date' ) . should ( 'have.value' , initialStartDate ) ;
462+ cy . getFormInputFieldById ( descriptionInputFieldId ) . should (
463+ 'have.value' ,
464+ initialDescription
465+ ) ;
466+ cy . getFormInputFieldById ( startDateInputFieldId ) . should (
467+ 'have.value' ,
468+ initialStartDate
469+ ) ;
453470
454471 /* ===== Checking whether Cancel button works ===== */
455472 cy . getFormFooterButtonByType ( cancelButton ) . should ( 'be.enabled' ) . click ( ) ;
0 commit comments