Firoj112 commited on
Commit
ed55bdf
·
verified ·
1 Parent(s): d68018d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -3
app.py CHANGED
@@ -71,9 +71,8 @@ def save_screenshot(memory_step: ActionStep, agent: CodeAgent) -> str:
71
  for previous_memory_step in agent.memory.steps:
72
  if isinstance(previous_memory_step, ActionStep) and previous_memory_step.step_number < current_step:
73
  previous_memory_step.observations_images = None
 
74
  original_size = driver.get_window_size()
75
- total_height = driver.execute_script("return document.body.scrollHeight")
76
- driver.set_window_size(original_size['width'], total_height)
77
  png_bytes = driver.get_screenshot_as_png()
78
  image = Image.open(BytesIO(png_bytes))
79
  screenshot_dir = os.path.join(tempfile.gettempdir(), "web_agent_screenshots")
@@ -82,7 +81,6 @@ def save_screenshot(memory_step: ActionStep, agent: CodeAgent) -> str:
82
  screenshot_filename = f"screenshot_step_{current_step}_{timestamp}.png"
83
  screenshot_path = os.path.join(screenshot_dir, screenshot_filename)
84
  image.save(screenshot_path)
85
- driver.set_window_size(original_size['width'], original_size['height'])
86
  logger.info(f"Saved screenshot to: {screenshot_path}")
87
  url_info = f"Current url: {driver.current_url}\nScreenshot saved at: {screenshot_path}"
88
  memory_step.observations = (
 
71
  for previous_memory_step in agent.memory.steps:
72
  if isinstance(previous_memory_step, ActionStep) and previous_memory_step.step_number < current_step:
73
  previous_memory_step.observations_images = None
74
+ # Capture only the viewport
75
  original_size = driver.get_window_size()
 
 
76
  png_bytes = driver.get_screenshot_as_png()
77
  image = Image.open(BytesIO(png_bytes))
78
  screenshot_dir = os.path.join(tempfile.gettempdir(), "web_agent_screenshots")
 
81
  screenshot_filename = f"screenshot_step_{current_step}_{timestamp}.png"
82
  screenshot_path = os.path.join(screenshot_dir, screenshot_filename)
83
  image.save(screenshot_path)
 
84
  logger.info(f"Saved screenshot to: {screenshot_path}")
85
  url_info = f"Current url: {driver.current_url}\nScreenshot saved at: {screenshot_path}"
86
  memory_step.observations = (