Skip to content

ElementQuery#last hrows IndexOutOfBoundsException instead of NoSuchElementException #1561

@probert94

Description

@probert94

Regarding the documentation, ElementQuery#last should throw a org.openqa.selenium.NoSuchElementException, when no element is foundbut it throws a java.lang.IndexOutOfBoundsException instead.
The reason for this is, that it calls List#get(index) instead of ElementQuery#get(index).

My current workaround is to use a function which looks like this:

public static <E extends TestBenchElement> E last(ElementQuery<E> query) {
    return query.get(query.all().size() - 1);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    🔖 Normal Priority (P2)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions