extend auto completion coverage (#1165)
This commit is contained in:
@@ -143,10 +143,6 @@ class SkyvernElement:
|
||||
if autocomplete and autocomplete == "list":
|
||||
return True
|
||||
|
||||
element_id = await self.get_attr("id")
|
||||
if element_id == "location-input":
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
async def is_custom_option(self) -> bool:
|
||||
@@ -527,6 +523,25 @@ class SkyvernElement:
|
||||
await self.focus(timeout=timeout)
|
||||
await asyncio.sleep(2) # wait for scrolling into the target
|
||||
|
||||
async def calculate_vertical_distance_to(
|
||||
self,
|
||||
target_locator: Locator,
|
||||
mode: typing.Literal["inner", "outer"],
|
||||
timeout: float = SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS,
|
||||
) -> float:
|
||||
self_rect = await self.get_locator().bounding_box(timeout=timeout)
|
||||
if self_rect is None:
|
||||
raise Exception("Can't Skyvern element rect")
|
||||
|
||||
target_rect = await target_locator.bounding_box(timeout=timeout)
|
||||
if self_rect is None or target_rect is None:
|
||||
raise Exception("Can't get the target element rect")
|
||||
|
||||
if mode == "inner":
|
||||
return abs(self_rect["y"] + self_rect["height"] - target_rect["y"])
|
||||
else:
|
||||
return abs(self_rect["y"] - (target_rect["y"] + target_rect["height"]))
|
||||
|
||||
|
||||
class DomUtil:
|
||||
"""
|
||||
|
||||
@@ -223,3 +223,7 @@ class SkyvernFrame:
|
||||
async def is_window_scrollable(self) -> bool:
|
||||
js_script = "() => isWindowScrollable()"
|
||||
return await self.evaluate(frame=self.frame, expression=js_script)
|
||||
|
||||
async def has_ASP_client_control(self) -> bool:
|
||||
js_script = "() => hasASPClientControl()"
|
||||
return await self.evaluate(frame=self.frame, expression=js_script)
|
||||
|
||||
Reference in New Issue
Block a user