Browserless Testing and package privat fields

I just generated some browserless tests with Claude Code and wondered why it accesses the internal components of a view directly.

Then I found this in the documentation:

test(helloView.name).setValue("Test");
test(helloView.sayHello).click();

IMO, doing this is bad style, and browserless testing should be done the same way as regular E2E tests and access the components using locators.

P.S.
It’s called package-private, not package-protected

I have seen it cutting the corners too, but even in more serious ways. Was too busy not to correct everything during the weekend/friday (I vibed a helper tool to help in our orienteering competitions we hosted yesterday). Just corrected one place, where it e.g. didn’t use tester and didn’t discover the “withText” locator:

The above is using a custom built version using the PR I mentioned to you last week (multiuser support & non-PHP naming for locators).

It think we have still quite a lot to improve the API in general (not just docs examples), so don’t hesitate to fill in proposals to GitHub directly. In addition to things mentioned already here, e.g. the setValue method name above is also quite a trap. The method names in the “testers” should IMO be describing the user actions. In Playwright that would be fill(String).

I have collected a dozen of these to my notebook during the last couple of weeks, but I think we might needs bigger refactoring plan based on this.

In general, I really like the concept (that I have been avoiding in my examples because it has forced commercial license).

1 Like

BTW. Regargind the original style issue, maybe it depends a bit of what “level” the tests are🤔 Like if testing a single view or a largers use case spanning over multiple views, don’t really have strong opinions with this little browserless-test view still.

That’s why I as using Karibu Testing for many years.

I’m on Mistral Vibe today and I can report it has the same problems :grimacing: “Now I need to add public getter methods to allow the test class to access the private components. Let me add these getters to the view class”

2 Likes