diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index e2f86f3..39345d0 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -17,7 +17,6 @@ def configure_selector_mock(): mock_response.html_content = "Test content" mock_response.encoding = "utf-8" mock_response.get_all_text.return_value = "Test content" - mock_response.css_first.return_value = mock_response mock_response.css.return_value = [mock_response] return mock_response diff --git a/tests/parser/test_general.py b/tests/parser/test_general.py index e5f8d59..808b65d 100644 --- a/tests/parser/test_general.py +++ b/tests/parser/test_general.py @@ -147,7 +147,7 @@ class TestTextMatching: class TestSimilarElements: def test_finding_similar_products(self, page): """Test finding similar product elements""" - first_product = page.css_first(".product") + first_product = page.css(".product").first similar_products = first_product.find_similar() assert len(similar_products) == 2 @@ -255,7 +255,7 @@ class TestElementNavigation: class TestJSONAndAttributes: def test_json_conversion(self, page): """Test converting content to JSON""" - script_content = page.css("#page-data::text")[0] + script_content = page.css("#page-data::text")[0].get() assert issubclass(type(script_content.sort()), str) page_data = script_content.json() assert page_data["totalProducts"] == 3 @@ -282,7 +282,7 @@ class TestJSONAndAttributes: assert list(key_value[0].keys()) == ["data-id"] # JSON attribute conversion - attr_json = page.css_first("#products").attrib["schema"].json() + attr_json = page.css("#products").first.attrib["schema"].json() assert attr_json == {"jsonable": "data"} assert isinstance(page.css("#products")[0].attrib.json_string, bytes) diff --git a/tests/parser/test_parser_advanced.py b/tests/parser/test_parser_advanced.py index 3ac81cf..57086ba 100644 --- a/tests/parser/test_parser_advanced.py +++ b/tests/parser/test_parser_advanced.py @@ -121,11 +121,12 @@ class TestAdvancedSelectors: # ::text pseudo-element texts = page.css("p::text") assert len(texts) == 2 - assert isinstance(texts[0], TextHandler) + assert isinstance(texts[0], Selector) + assert isinstance(texts[0].get(), TextHandler) # ::attr() pseudo-element attrs = page.css("div::attr(class)") - assert "container" in attrs + assert "container" in attrs.getall() def test_complex_attribute_operations(self, complex_html): """Test complex attribute handling"""