Skip to content

Optimize find_visible_elements(selector) when a limit is specified #2531

@mdmintz

Description

@mdmintz

Optimize find_visible_elements(selector) when a limit is specified

The method:

find_visible_elements(selector, by="css selector", limit=0)

"""Returns a list of matching WebElements that are visible.
If "limit" is set and > 0, will only return that many elements."""

If a limit is set, the current algorithm truncates the list after checking if elements are visible. That's inefficient. The algorithm should be updated so that truncation is done before checking visibility (in case there is a really long list of elements present... in which case there would be a noticeable slowdown). There may be an edge case where the number of visible elements for a selector is less that the number of elements present for that selector... in that edge case, additional elements may have to be added back, and checked for visibility status, before being included in the returned list.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions