mercredi 22 janvier 2020

Assertion error when IDs are same for different behaviors of an element

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()

Aucun commentaire:

Enregistrer un commentaire