I want to make sure that I can login. It’s a very simple test:
class LoginViewTest extends KaribuTest {
@Test
void nathanCanLoginWithForm() throws Exception {
_get(TextField.class, spec -> spec.withId("vaadinLoginUsername")).setValue("user@email.com");
}
Result
java.lang.AssertionError: /login: No visible TextField in UI matching TextField and id=‘vaadinLoginUsername’: . Component tree:
└── UI
└── LoginView
└── Button[text=‘Register New User’, @slot=‘custom-form-area’]
This is confusing because when I render the html and inspect, I can see the field with the id:
HTML
<form method="POST" slot="form" action="login" data-bitwarden-watching="1">
<input id="csrf" type="hidden">
<vaadin-text-field name="username" id="vaadinLoginUsername" required="" autocapitalize="none" autocorrect="off" spellcheck="false" autocomplete="username" has-label="" invalid="" has-error-message="">
<input type="text" slot="input" id="input-vaadin-text-field-6" required="" name="username" autocapitalize="none" autocomplete="username" autocorrect="off" aria-labelledby="label-vaadin-text-field-0" aria-invalid="true" invalid="" aria-describedby="error-message-vaadin-text-field-2">
<label slot="label" id="label-vaadin-text-field-0" for="input-vaadin-text-field-6">Username</label><div slot="error-message" id="error-message-vaadin-text-field-2" role="alert">Username is required</div></vaadin-text-field>
<vaadin-password-field ...</vaadin-password-field>
</form>