[BUG] ScrapeElementFromWebsiteTool breaks when only website_url or only css_element is set at init

Abierto
#9,873 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@p-tirth ya está trabajando en esto.

Desde el 27/11/2026.

  • #9874 de @p-tirth — abierto
  • #9890 de @Mansi2221 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
backend

Línea de trabajo

The issue names ScrapeElementFromWebsiteTool and SeleniumScrapingTool but no source or test file paths. Start by locating the tool implementation and its tests, then check how initialization selects the argument schema and stores each fixed value. Done means either initialization option can be fixed independently, the remaining argument is requested, and tests cover both cases.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

The docs for ScrapeElementFromWebsiteTool describe website_url and css_element as independently optional at initialization: "If provided during initialization, the agent won't need to specify it when using the tool." That only holds when both are given. Fixing just one of them breaks the tool.

  • Only website_url fixed: the tool switches to the empty FixedScrapeElementFromWebsiteToolSchema, so the agent is never asked for css_element and every run raises Both website_url and css_element must be provided.
  • Only css_element fixed: the value is dropped, because it is only stored inside if website_url is not None:. The agent is still asked for a selector.
Steps to Reproduce
from unittest.mock import MagicMock, patch
from crewai_tools import ScrapeElementFromWebsiteTool

MODULE = "crewai_tools.tools.scrape_element_from_website.scrape_element_from_website"
page = MagicMock(content=b"<html><h1>Title</h1><p class='price'>$10</p></html>")

with patch(f"{MODULE}.safe_get", return_value=page):
    a = ScrapeElementFromWebsiteTool(website_url="https://example.com")
    print(list(a.args_schema.model_fields))   # []
    a.run()                                   # ValueError: Both website_url and css_element must be provided.

    b = ScrapeElementFromWebsiteTool(css_element=".price")
    print(b.css_element)                      # None
    print(list(b.args_schema.model_fields))   # ['website_url', 'css_element']
Expected behavior
  • With only website_url fixed, the schema asks the agent for css_element.
  • With only css_element fixed, the selector is kept and the schema asks the agent for website_url.

SeleniumScrapingTool already stores css_element on its own, outside the website_url check.

Environment
  • crewAI and crewAI Tools 1.15.45 (main at 77237ae)
  • Python 3.13, macOS
Possible Solution

Store css_element independently and pick the args schema from what was fixed at init. I have this ready with tests and will open a PR.

Additional context

I used an AI coding assistant while working on this.

Lenguaje dominante
Python
Estrellas
61.2k
Forks
9.2k
Merge medio
1 d 14 h
PR fusionados (30 d)
180

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de crewAIInc/crewAI

Todos los issues de crewAIInc/crewAI

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.