Skip to content

Keep list methods available when ElementList is empty - #1335

Open
oyeong011 wants to merge 1 commit into
cobrateam:masterfrom
oyeong011:fix/empty-element-list-methods
Open

oyeong011 wants to merge 1 commit into
cobrateam:masterfrom
oyeong011:fix/empty-element-list-methods

Conversation

@oyeong011

Copy link
Copy Markdown

Empty ElementList results currently raise ElementDoesNotExist for ordinary list methods such as append, extend, and count because attribute lookup accesses first before checking the underlying list. Clearing a nonempty list also leaves append unusable.

Allow existing list attributes to resolve directly when the collection is empty. Nonempty first-element forwarding and the existing missing-element exception for actions such as click remain unchanged. Four regression tests cover append, extend, count, and clear followed by append.

Validation: Python 3.12.13, python -m pytest --ignore-flaky tests/tests_splinter -q: 28 passed. pre-commit run --all-files: all hooks passed. Four new tests failed on the original code. Direct public ElementList API QA also passed, including the preserved missing-element query diagnostic. WebDriver browser matrix was not run because this is a backend-independent collection dispatch change.

AI disclosure: This contribution was prepared with OpenAI Codex assistance; the reproduction, patch, and validation were executed locally. Maintainer review is requested.

Empty query results and cleared collections should support their documented list operations without requiring a first element.

Confidence: high
Scope-risk: narrow
Tested: 28 platform-agnostic tests; pre-commit all-files; public API QA
Not-tested: WebDriver browser matrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant