Skip to content

Commit

Permalink
Added minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
dhuynh-lovable committed Sep 24, 2024
1 parent 6168fba commit abab126
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lavague-core/lavague/exporter/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def on_missing_action(self, action: Action) -> None:

def translate_action(self, action: Action) -> Optional[str]:
"""Translate a single action to target framework code"""
instruction = action.instruction

match action.action_type:
case ActionType.NAVIGATION:
Expand All @@ -47,6 +48,7 @@ def translate_action(self, action: Action) -> Optional[str]:
case _:
self.on_missing_action(action)

output = f"# {instruction}\n{output}\n"
return output

def translate_click(self, action_output: NavigationOutput) -> Optional[str]:
Expand Down
8 changes: 5 additions & 3 deletions lavague-core/lavague/exporter/python.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from contextlib import contextmanager
import inspect
import re
from functools import wraps
from typing import Callable, Optional, List
from lavague.exporter.base import TrajectoryExporter
from lavague.action.base import ActionType
Expand Down Expand Up @@ -36,7 +34,7 @@ class PythonExporter(TrajectoryExporter):
"""

@classmethod
def translate(cls, method: Callable, output: NavigationOutput, string_only: bool = True) -> Optional[str]:
def translate(cls, method: Callable, output: NavigationOutput | ExtractionOutput, string_only: bool = True) -> Optional[str]:
"""Takes the code of method, replace each use of the 'action' parameter with the actual action attributes.
Replacement is done only on attributes of the action used in the method.
"""
Expand Down Expand Up @@ -169,6 +167,10 @@ def hover(self, action: NavigationOutput) -> Optional[str]:
driver = self.get_driver()
driver.find_element(By.XPATH, action.xpath).hover()

def set_value(self, action: NavigationOutput) -> Optional[str]:
driver = self.get_driver()
driver.find_element(By.XPATH, action.xpath).send_keys(action.value)

def extract(self, action: ExtractionOutput) -> Optional[str]:

driver = self.get_driver()
Expand Down

0 comments on commit abab126

Please sign in to comment.