vaadin / testbench

Vaadin TestBench is a tool for automated user interface testing of Vaadin applications.
https://vaadin.com/testbench
Other
20 stars 22 forks source link

AnchorTester should support Anchors having query parameters #1811

Closed joelpop closed 3 months ago

joelpop commented 4 months ago

Currently AnchorTester fails when click-testing an Anchor having query parameters in its href because the location parameter of the navigate method does not accept them.

So instead of calling

UI.getCurrent().navigate(getComponent().getHref());

the path and the query parameters should be passed separately, as in

UI.getCurrent().navigate(getPath(), getQueryParameters());

where the following methods are present

    /**
     * Gets the path for the router-link.
     * Returns an empty {@link String} if there is no corresponding navigation target.
     *
     * @return a {@link String} containing the navigation target path or empty if not present
     */
    public String getPath() {
        return URI.create(getHref()).getPath();
    }

    /**
     * Gets the query parameters for the router-link.
     *
     * @return a {@link QueryParameters} containing the navigation target's query parameters
     */
    public QueryParameters getQueryParameters() {
        return QueryParameters.fromString(URI.create(getHref()).getQuery());
    }

which is how RouterLinkTester is implemented.