mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
Merge remote-tracking branch 'origin/main' into output-history
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
@@ -16,12 +14,12 @@ def llm():
|
||||
@pytest.fixture
|
||||
async def controller():
|
||||
"""Initialize the controller"""
|
||||
controller = Controller()
|
||||
controller = Controller(keep_open=False)
|
||||
try:
|
||||
yield controller
|
||||
finally:
|
||||
if controller.browser:
|
||||
controller.browser.close(force=True)
|
||||
await controller.browser.close(force=True)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -168,15 +166,15 @@ async def test_scroll_down(llm, controller):
|
||||
)
|
||||
# Get the browser instance
|
||||
browser = controller.browser
|
||||
driver = browser._get_driver()
|
||||
page = await browser.get_current_page()
|
||||
|
||||
# Navigate to the page and get initial scroll position
|
||||
await agent.run(max_steps=1)
|
||||
initial_scroll_position = driver.execute_script('return window.pageYOffset;')
|
||||
initial_scroll_position = await page.evaluate('window.scrollY;')
|
||||
|
||||
# Perform the scroll down action
|
||||
await agent.run(max_steps=2)
|
||||
final_scroll_position = driver.execute_script('return window.pageYOffset;')
|
||||
final_scroll_position = await page.evaluate('window.scrollY;')
|
||||
|
||||
# Validate that the scroll position has changed
|
||||
assert final_scroll_position > initial_scroll_position, 'Page did not scroll down'
|
||||
|
||||
Reference in New Issue
Block a user