cremote/test_dropdown.py

54 lines
1.7 KiB
Python

#!/usr/bin/env python3
import requests
import json
# Test the dropdown selection fix
def test_dropdown_selection():
url = "http://localhost:8080/interact-multiple"
# Test data - select by value "CA"
data = {
"interactions": [
{
"selector": "[name='state']",
"action": "select",
"value": "CA"
}
],
"timeout": 15
}
print("Testing dropdown selection by value 'CA'...")
response = requests.post(url, json=data)
if response.status_code == 200:
result = response.json()
print(f"Response: {json.dumps(result, indent=2)}")
# Check if it was successful
if result.get('success_count', 0) > 0:
print("✅ SUCCESS: Dropdown selection worked!")
else:
print("❌ FAILED: Dropdown selection failed")
# Verify the actual value was set
verify_url = "http://localhost:8080/eval-js"
verify_data = {"code": "document.querySelector('[name=\"state\"]').value"}
verify_response = requests.post(verify_url, json=verify_data)
if verify_response.status_code == 200:
actual_value = verify_response.json().get('result', '')
print(f"Actual dropdown value: '{actual_value}'")
if actual_value == 'CA':
print("✅ VERIFICATION: Value correctly set to 'CA'")
else:
print(f"❌ VERIFICATION: Expected 'CA' but got '{actual_value}'")
else:
print("❌ Could not verify dropdown value")
else:
print(f"❌ HTTP Error: {response.status_code}")
print(response.text)
if __name__ == "__main__":
test_dropdown_selection()