Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

testig element highlighting

Gregor Žunič7729da697188
diff --git a/browser_use/browser/tests/highlight_elements.py b/browser_use/browser/tests/highlight_elements.py
index e9b7f3d17..014fe552e 100644
--- a/browser_use/browser/tests/highlight_elements.py
+++ b/browser_use/browser/tests/highlight_elements.py
@@ -1,7 +1,7 @@
+import base64
+import os
import time
-from tokencost import count_string_tokens
-
from browser_use.browser.service import BrowserService
from browser_use.dom.service import DomService
from browser_use.utils import time_execution_sync
@@ -25,12 +25,16 @@ def test_highlight_elements():
elements = time_execution_sync('get_clickable_elements')(dom_service.get_clickable_elements)()
- time_execution_sync('highlight_selector_map_elements')(browser.highlight_selector_map_elements)(
- elements.selector_map
- )
+ # time_execution_sync('highlight_selector_map_elements')(browser.highlight_selector_map_elements)(
+ # elements.selector_map
+ # )
+
+ image = time_execution_sync('take_screenshot')(browser.take_screenshot)(elements.selector_map)
- input('Press Enter to continue...')
+ temp_image_path = os.path.join(os.path.dirname(__file__), 'temp', 'temp.png')
+ with open(temp_image_path, 'wb') as f:
+ f.write(base64.b64decode(image))
- time_execution_sync('remove_highlights')(browser.remove_highlights)()
+ # time_execution_sync('remove_highlights')(browser.remove_highlights)()
input('Press Enter to continue...')
diff --git a/browser_use/dom/tests/extraction_test.py b/browser_use/dom/tests/extraction_test.py
index 317dd02ba..f4b7e8d70 100644
--- a/browser_use/dom/tests/extraction_test.py
+++ b/browser_use/dom/tests/extraction_test.py
@@ -1,7 +1,5 @@
import time
-from selenium.webdriver.common.by import By
-from selenium.webdriver.support.ui import WebDriverWait
from tokencost import count_string_tokens
from browser_use.browser.service import BrowserService