how to create a page object with css identifer & attribute -
how define page object css identifier attribute
for example, <div class="presc" date-range="3 months">3m</div> <div class="presc selected" date-range="6 months">6m</div> <div class="presc" date-range="1 year">1y</div>
how use attribute name data-range?
div(:date_range_3m, css:div.prescription[@data-range = '3 month')
the accessor want is:
div(:date_range_3m, css: 'div.presc[date-range~="3"][date-range~="months"]')
some notes changes/problems:
- the
date-range="3 months"
considered attribute space separated value list. these types of values, can compare against each of individual words. why suggested selector has[date-range~="3"][date-range~="months"]
. note has problem matchdate-range="months 3"
date-range="3 months other values"
. - the class value "presc" rather "prescription".
- the attribute on element "date-range" instead of "data-range".
- unlike xpath, css-selectors not prefix attribute "@"
- the quotations around css value missing.
- there mismatched ending bracket - should "]" instead of ")".
Comments
Post a Comment