adding new extract command to extract selector or main content as markdown, updateing version as 0.5.0
This commit is contained in:
@@ -7,18 +7,24 @@ def test_extract_links(browser, http_tab):
|
||||
browser("tabs.active", {"tabId": http_tab["id"]})
|
||||
links = browser("extract.links")
|
||||
assert isinstance(links, list)
|
||||
hrefs = []
|
||||
for lnk in links:
|
||||
assert "href" in lnk
|
||||
assert "text" in lnk
|
||||
hrefs.append(lnk["href"])
|
||||
assert len(hrefs) == len(set(hrefs))
|
||||
|
||||
|
||||
def test_extract_images(browser, http_tab):
|
||||
browser("tabs.active", {"tabId": http_tab["id"]})
|
||||
images = browser("extract.images")
|
||||
assert isinstance(images, list)
|
||||
sources = []
|
||||
for img in images:
|
||||
assert "src" in img
|
||||
assert img["src"] != ""
|
||||
sources.append(img["src"])
|
||||
assert len(sources) == len(set(sources))
|
||||
|
||||
|
||||
def test_extract_text(browser, http_tab):
|
||||
@@ -35,6 +41,19 @@ def test_extract_html(browser, http_tab):
|
||||
assert "<" in html
|
||||
|
||||
|
||||
def test_extract_markdown(browser, http_tab):
|
||||
browser("tabs.active", {"tabId": http_tab["id"]})
|
||||
markdown = browser("extract.markdown")
|
||||
assert isinstance(markdown, str)
|
||||
assert len(markdown.strip()) > 0
|
||||
|
||||
|
||||
def test_extract_markdown_missing_selector_errors(browser, http_tab):
|
||||
browser("tabs.active", {"tabId": http_tab["id"]})
|
||||
with pytest.raises(RuntimeError, match="No element"):
|
||||
browser("extract.markdown", {"selector": ".browser-cli-definitely-missing"})
|
||||
|
||||
|
||||
def test_dom_exists(browser, http_tab):
|
||||
browser("tabs.active", {"tabId": http_tab["id"]})
|
||||
result = browser("dom.exists", {"selector": "body"})
|
||||
|
||||
Reference in New Issue
Block a user