Skip to content

Commit

Permalink
fix: in viewport retriever JS
Browse files Browse the repository at this point in the history
  • Loading branch information
adeprez committed Oct 8, 2024
1 parent a3190b6 commit e15cb6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.chrome.service import Service


class SeleniumDriver(BaseDriver[SeleniumNode]):
driver: WebDriver

Expand Down Expand Up @@ -186,6 +187,7 @@ def get_possible_interactions(
self,
in_viewport=True,
foreground_only=True,
include_non_interactives=False,
types: List[InteractionType] = [
InteractionType.CLICK,
InteractionType.TYPE,
Expand All @@ -197,12 +199,14 @@ def get_possible_interactions(
JS_GET_INTERACTIVES,
in_viewport,
foreground_only,
False,
include_non_interactives,
[t.name for t in types],
)
res = dict()
for k, v in exe.items():
res[k] = set(InteractionType[i] for i in v)
res[k] = set(
InteractionType[i] for i in v if i in InteractionType.__members__
)
return res

def scroll_into_view(self, xpath: str):
Expand Down
5 changes: 4 additions & 1 deletion lavague-sdk/lavague/sdk/base_driver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def get_possible_interactions(
self,
in_viewport=True,
foreground_only=True,
include_non_interactives=False,
types: List[InteractionType] = [
InteractionType.CLICK,
InteractionType.TYPE,
Expand Down Expand Up @@ -232,7 +233,9 @@ def get_obs(self) -> DriverObservation:

def get_in_viewport(self) -> List[str]:
"""Get xpath of elements in the viewport"""
interactions = self.get_possible_interactions(in_viewport=True, types=[])
interactions = self.get_possible_interactions(
include_non_interactives=True, types=[]
)
return list(interactions.keys())

def get_scroll_containers(self) -> List[str]:
Expand Down

0 comments on commit e15cb6b

Please sign in to comment.