We wish to assert the value of “Received” column for “Style Guide for ZK 3.5 released”. If we bring up the controller and CTRL-hover over that element, what we see is
which is not useful as a finder.
Looking at the alternatives listed, we notice that none of them can really help.
To fix this, we shall try using _near.
1) We put
_div(0, _near(_div(“Style Guide for ZK 3.5 released”)))
into the Evaluate Expression box, and click Highlight. This highlights the “Style Guide” element itself.
2) We experiment with the index passed as the first parameter, and using Highlight, pinpoint on the correct accessor as
_div(4, _near(_div(“Style Guide for ZK 3.5 released”)))
But this will not make a good accessor
Because, this uses an index which seems like it would change when another column is added before the Received column.
What we really want, is that element, which is UNDER _div(“Received”).
Introducing the _under API
_under is a POSITIONAL marker. What it means is that it checks for coordinate based alignment under a particular element within a specific threshold.
So, in our case, it will look for a div which is roughly positioned underneath _div(“Received”)
Here is the final accessor:
_div(0, _near(_div(“Style Guide for ZK 3.5 released”)), _under(_div(“Received”)))
Note how this accessor is independent of the order of the rows and the columns.
And then the testers lived happily ever after …
This grid is not a simple table but actually composed of 2 tables, one for the header and one for the contents. So we could have approaced this problem using _cell(_table(2), “Style Guide for ZK 3.5 released”, 4), but again the 4 would trip us later if the order/number of columns changes.
_under(el) can be passed as a last parameter to any Sahi API.
NOTE: _under will be available in Sahi’s next release