nightwatch.js - In Magellan / Nightwatch, how do we assert that an element comes before another element? -
for example, if user has gift card, want assert gift card section comes first:
<section id="gift-card-section"> ... </section> <section id="credit-card-section"> ... </section>
otherwise, want assert credit card section comes first. how can done in magellan / nightwatch?
my thinking n
in n-th child
... , assert n1
< n2
or other way around. how done in magellan / nightwatch?
this great case using xpath. explicit, if know these should first , second section elements.
browser .usexpath().assert.attributecontains('(//section)[1]', 'id', 'gift-card-section'); .usexpath().assert.attributecontains('(//section)[2]', 'id', 'credit-card-section');
or, if need not ordered, , @ same level in dom (if siblings) use attribute equals:
browser .usexpath().assert.attributeequals("//section[@id='credit-card-section']/following-sibling:://section[@id='gift-card-section']", "id", "credit-card-section");
this second option bit redundant, there plenty of other options if using xpath in nightwatch.
Comments
Post a Comment