Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't interact with fields that are already filled in #181

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions skyvern/forge/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ async def _build_and_record_step_prompt(
for window_step in window_steps:
if window_step.output and window_step.output.action_results:
action_results.extend(window_step.output.action_results)

action_results_str = json.dumps([action_result.model_dump() for action_result in action_results])
# Generate the extract action prompt
navigation_goal = task.navigation_goal
Expand Down
2 changes: 1 addition & 1 deletion skyvern/forge/sdk/workflow/models/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async def execute(self, workflow_run_id: str, **kwargs: dict) -> BlockResult:
raise TaskNotFound(task.task_id)
if not updated_task.status.is_final():
raise UnexpectedTaskStatus(task_id=updated_task.task_id, status=updated_task.status)
if updated_task.status == TaskStatus.completed:
if updated_task.status == TaskStatus.completed or updated_task.status == TaskStatus.terminated:
LOG.info(
f"Task completed",
task_id=updated_task.task_id,
Expand Down
8 changes: 8 additions & 0 deletions skyvern/webeye/actions/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ async def handle_input_text_action(
) -> list[ActionResult]:
xpath = await validate_actions_in_dom(action, page, scraped_page)
locator = page.locator(f"xpath={xpath}")

current_text = await locator.input_value()
if current_text == action.text:
return [ActionSuccess()]

await locator.clear()
text = get_actual_value_of_parameter_if_secret(task, action.text)
await locator.fill(text, timeout=SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS)
Expand Down Expand Up @@ -313,6 +318,9 @@ async def handle_select_option_action(
)
return [ActionFailure(Exception(f"Cannot handle SelectOptionAction on a non-listbox element"))]

current_text = await locator.input_value()
if current_text == action.option.label:
return ActionSuccess()
try:
# First click by label (if it matches)
await page.click(f"xpath={xpath}", timeout=SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS)
Expand Down
7 changes: 3 additions & 4 deletions skyvern/webeye/scraper/domUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ function buildTreeFromBody() {
const selectContainers = document.querySelectorAll(".select2-container");

selectContainers.forEach((element) => {
// hide the select2 container
element.style.display = "none";

// search select in previous
let _pre = element.previousElementSibling;
while (_pre) {
Expand All @@ -513,8 +516,6 @@ function buildTreeFromBody() {
_pre.style.display === "none"
) {
_pre.style.removeProperty("display");
// only hide the select2 container when an alternative select found
element.style.display = "none";
return;
}
_pre = _pre.previousElementSibling;
Expand All @@ -528,8 +529,6 @@ function buildTreeFromBody() {
_next.style.display === "none"
) {
_next.style.removeProperty("display");
// only hide the select2 container when an alternative select found
element.style.display = "none";
return;
}
_next = _next.nextElementSibling;
Expand Down
Loading