Skip to content

Commit 7a27966

Browse files
committed
returned the iterator and corrected the test
1 parent c6f0251 commit 7a27966

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

‎browserbase/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,13 @@ def load_urls(self, urls: List[str]):
3737
"wss://api.browserbase.com?apiKey=" + self.api_key
3838
)
3939

40-
html_contents = []
4140
for url in urls:
4241
page = browser.new_page()
4342
page.goto(url)
44-
html = page.content()
45-
html_contents.append(html)
46-
page.close()
43+
yield page.content()
4744

4845
browser.close()
4946

50-
return html_contents
51-
5247
def screenshot(self, url: str, full_page: bool = False):
5348
"""Load a page in a headless browser and return a screenshot as base64 string"""
5449
if not url:

‎tests/lib.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ def test_load(self):
1212
self.assertIn("Example Domain", result)
1313

1414
def test_load_urls(self):
15-
result = self.browserbase.load_urls(["https://example.com"])
16-
self.assertIn("Example Domain", result[0])
15+
result = next(self.browserbase.load_urls(["https://example.com"]))
16+
self.assertIn("Example Domain", result)
1717

1818
def test_screenshot(self):
1919
result = self.browserbase.screenshot("https://example.com")
20-
print(result)
21-
self.assertIn("Example Domain", result)
20+
self.assertIn("oq0IBiQAAAABJRU5ErkJggg==", result)
2221

2322

2423
if __name__ == "__main__":

0 commit comments

Comments
 (0)