[Add] browser-use and main.py
This commit is contained in:
parent
08e64bdf45
commit
96914d44ac
221 changed files with 30952 additions and 1 deletions
44
browser-use/tests/test_dropdown_complex.py
Normal file
44
browser-use/tests/test_dropdown_complex.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
"""
|
||||
Test complex dropdown interaction functionality.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from browser_use.agent.service import Agent
|
||||
from browser_use.agent.views import AgentHistoryList
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dropdown_complex(llm, browser_context):
|
||||
"""Test selecting an option from a complex dropdown menu."""
|
||||
agent = Agent(
|
||||
task=(
|
||||
'go to https://codepen.io/shyam-king/pen/pvzpByJ and first get all options for the dropdown and then select the json option'
|
||||
),
|
||||
llm=llm,
|
||||
browser_context=browser_context,
|
||||
)
|
||||
|
||||
try:
|
||||
history: AgentHistoryList = await agent.run(20)
|
||||
result = history.final_result()
|
||||
|
||||
# Verify dropdown interaction
|
||||
assert result is not None
|
||||
assert 'json' in result.lower(), "Expected 'json' option to be selected"
|
||||
|
||||
# Verify dropdown state
|
||||
element = await browser_context.get_element_by_selector('.select-selected')
|
||||
assert element is not None, 'Custom dropdown element should exist'
|
||||
|
||||
text = await element.text_content()
|
||||
assert 'json' in text.lower(), 'Dropdown should display json option'
|
||||
|
||||
# Verify the selected option's effect
|
||||
code_element = await browser_context.get_element_by_selector('pre code')
|
||||
assert code_element is not None, 'Code element should be visible when JSON is selected'
|
||||
|
||||
except Exception as e:
|
||||
pytest.fail(f'Complex dropdown test failed: {str(e)}')
|
||||
finally:
|
||||
await browser_context.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue