1

I am dabbling with a Role based access situation and am sort of stuck on the assertion.

For the Full Access the field is like so

<input class="clickable_input clickable_timeholder ui-autocomplete-input ui-widget ui-widget-content ui-corner-left hidden" data-old-value="12:00 am" type="text" value="12:00 am" name="program_constraint[event_window_constraints_attributes][0][local_start_time]" id="program_constraint_event_window_constraints_attributes_0_local_start_time" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">

For the Readonly access the field is like so

<input class="hidden clickable_input clickable_timeholder" data-old-value="12:00 am" type="text" value="12:00 am" name="program_constraint[event_window_constraints_attributes][0][local_start_time]" id="program_constraint_event_window_constraints_attributes_0_local_start_time"></input>

I would like to work with only 1 selector that is the one with the full access and then check for exists or not to pass or fail the case.

I end up with the below assertion error primarily because both the conditions use the same ID and the only difference is in their class name. I have not found a good example yet to handle this. Being still a week old into working w/TestCafe, I understand the DOM model perfectly fine, I can't seem to quite incorporate this into a page model effectively and keep hitting a wall.

expected true to be falsy

This is my Selector definition in the page model:

this.eventWindowStartTime = Selector("#program_constraint_event_window_constraints_attributes_0_local_start_time")

my Test code for the assertion

await t.expect(programOptionsConstraintsPage.eventWindowStartTime.exists).notOk()
Vladimir A.
  • 2,202
  • 2
  • 10
  • 28
Anjana
  • 89
  • 6

1 Answers1

2

You can use the filter method to find only an element with a particular css class.

For example:

Selector('#input_id').filter('.ui-widget')
Dmitry Ostashev
  • 2,305
  • 1
  • 5
  • 21
  • In a Page Model where I am defining this upfront, I need this to be generic enough and apply the filtering in the assertion I suppose. – Anjana Jan 23 '20 at 16:03