• +43 660 1453541
  • contact@germaniumhq.com

Germanium 1.9.0 has Amazing Positional Filtering




Germanium 1.9.0 has Amazing Positional Filtering

With the release of Germanium 1.9.0, not only the positional filtering was completely rewritten (keeping 100% backwards compatibility), but finding items positionally is incredibly simple now.

For example when we’re selecting items below a given element, we generally want the item exactly under our reference point. When we type keys using the following selector:

1
2
type_keys("user@email.com",
Input().below(Text("E-Mail")))

we obviously want to ignore everything that is above the E-Mail text. But what we also want is to type exactly into the input below the given text, even if multiple inputs are technically below it. Since Germanium 1.9.0 the ordering is guaranteed to be far more stable, and return the element_list() in the following order:

General Sorting Overview

Basically elements exactly below our reference element have priority, and the others are still sorted as distance from their top-left corner.

This is why element() will always return what we expect it to, and we can also support scenarios such as writing into the next input right of, without nesting right_of calls. So if we would have this scenario:

General Sorting Overview

in order to pick the 2nd select from the Start Time row, we would do:

1
2
3
right_select = Element("select").right_of(
Text("Start Time")).element_list(1)
select("05", right_select)

General Sorting Overview

Personally I prefer this instead of:

1
2
3
4
right_select = Element("select").right_of(
Element("select").right_of(
Text("Start Time")))
select("05", right_select)

The reason is not only performance, since obviously it’s better to filter and search elements only once instead of twice, but also I find it generally a better usage, since it allows typing into data grids naturally, instead of always nesting right_of calls. Want to type into the 4th column? Just element_list(3) and be done with it.