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

Aperta
#9,873 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@p-tirth ci sta già lavorando.

Dal 27/11/2026.

  • #9874 di @p-tirth — aperta
  • #9890 di @Mansi2221 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
61.2k
Fork
9.2k
Merge medio
1g 14h
PR unite (30g)
180

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di crewAIInc/crewAI

Tutte le issue di crewAIInc/crewAI

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.