vaadin / vaadin/browserless-test

Agent DX improvement: Value-bearing locators are write-only — no `getValue()` anywhere

Open
#152 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1
Forks
3
Avg merge
1d 20h
Merged PRs (30d)
51

Description

Problem. Every field locator can write a value but none can read one. The
locators otherwise read as if they proxy the component, so getValue() is the
first thing you reach for, and it doesn't compile.

Surveyed in browserless-test-shared:1.1.1:

Locator setValue clear value getter
TextFieldLocator
TextAreaLocator
BigDecimalFieldLocator
NumberFieldLocator
IntegerFieldLocator
EmailFieldLocator / PasswordFieldLocator
DatePickerLocator / DateTimePickerLocator / TimePickerLocator
ComboBoxLocator / SelectLocator ❌ (selectItem) getSelected()
CheckboxLocator ❌ (click)

So a test that asserts "this field defaults to 1" has to leave the locator API:

// Wanted
assertThat(findBigDecimalField().withLabel("Quantity").getValue())
        .isEqualByComparingTo("1");

// Actual
assertThat(findBigDecimalField().withLabel("Quantity").getComponent().getValue())
        .isEqualByComparingTo("1");

Why it's cheap to fix. HasValueFilter<C extends Component & HasValue<?, V>, V, SELF>
already binds both the component type and the value type — it exists to power
withValue(V). A default accessor on that interface (or a sibling
HasValueAccess) gives every value locator a typed, correct getter with no
per-locator work:

default V getValue() { return ((Locator<C, SELF>) this).component().getValue(); }

Ask. Add getValue() to the value-bearing locators (ideally as one default
method on the existing filter/accessor interface). Keep getSelected() on
ComboBoxLocator/SelectLocator as an alias if the selection vocabulary is
deliberate, but make getValue() work everywhere setValue/withValue does.

Copied from https://github.com/vaadin/agentic-dx-improvement/issues/107

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with HasValueFilter and the value-bearing locator interfaces, following the existing withValue/setValue path and component().getValue() access. Verify that getValue() is available for every locator supporting value operations, preserve getSelected() for ComboBoxLocator and SelectLocator, and add or update tests for the typed getter behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.