test: update the tests accordingly
This commit is contained in:
@@ -17,7 +17,6 @@ def configure_selector_mock():
|
||||
mock_response.html_content = "<html><body>Test content</body></html>"
|
||||
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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user