Skip to content

Commit

Permalink
⬇️ Test to make sure hidden dropdown elements are not being tagged (#141
Browse files Browse the repository at this point in the history
)

* ⬇️ Test to make sure hidden dropdown elements are not being tagged

* ⬇️ Added testing against page_text

* ⬇️ reformat

* ⬇️ test individual characters for expected_tag_string

* add test to make sure hidden dropdown elements are not present in page_text

* rm print

* 🖼️ reformat
  • Loading branch information
seanmcguire12 authored Aug 29, 2024
1 parent 2bd13f9 commit e7e2ab6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
17 changes: 17 additions & 0 deletions tests/mock_html/dropdown.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Title</title>
</head>
<body>
<label>
<select style="font-size: xx-large">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
</select>
</label>
</body>
</html>
31 changes: 30 additions & 1 deletion tests/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,19 @@
IS_GITHUB_ACTIONS, reason="Skipping language test in CI"
),
),
(
"mock_html/dropdown.html",
{
0: "//html/body/label",
},
["Option 1"],
["[ $ 0 ]"],
),
(
"mock_html/iframe.html",
{0: "iframe[0]//html/body/p"},
{
0: "iframe[0]//html/body/p",
},
["This is some text content inside the iframe"],
["[ 0 ]"],
),
Expand Down Expand Up @@ -198,3 +208,22 @@ async def test_text_nodes_are_query_selectable(async_page):
assert len(tag_to_xpath) == 2
assert await async_page.query_selector(tag_to_xpath[0])
assert await async_page.query_selector(tag_to_xpath[1])


@pytest.mark.asyncio
async def test_dropdown_text_not_shown(tarsier, async_page):
dropdown_html_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), "mock_html/dropdown.html")
)
await async_page.goto(f"file://{dropdown_html_path}")
page_text, tag_to_xpath = await tarsier.page_to_text(
async_page, tag_text_elements=True
)

assert "[ $ 1 ]" not in page_text
assert "[ $ 2 ]" not in page_text
assert "[ $ 3 ]" not in page_text
assert "[ $ 4 ]" not in page_text
assert "Option 2" not in page_text
assert "Option 3" not in page_text
assert "Option 4" not in page_text

0 comments on commit e7e2ab6

Please sign in to comment.