This commit is contained in:
Josh at WLTechBlog
2025-08-19 06:15:55 -05:00
parent 58e361ba70
commit 36adab7878
9 changed files with 506 additions and 46 deletions

View File

@@ -325,6 +325,41 @@ func (c *Client) UploadFile(tabID, selector, filePath string, selectionTimeout,
return nil
}
// SelectElement selects an option in a select dropdown
// If tabID is empty, the current tab will be used
// selectionTimeout and actionTimeout are in seconds, 0 means no timeout
func (c *Client) SelectElement(tabID, selector, value string, selectionTimeout, actionTimeout int) error {
params := map[string]string{
"selector": selector,
"value": value,
}
// Only include tab ID if it's provided
if tabID != "" {
params["tab"] = tabID
}
// Add timeouts if specified
if selectionTimeout > 0 {
params["selection-timeout"] = strconv.Itoa(selectionTimeout)
}
if actionTimeout > 0 {
params["action-timeout"] = strconv.Itoa(actionTimeout)
}
resp, err := c.SendCommand("select-element", params)
if err != nil {
return err
}
if !resp.Success {
return fmt.Errorf("failed to select element: %s", resp.Error)
}
return nil
}
// SubmitForm submits a form
// If tabID is empty, the current tab will be used
// selectionTimeout and actionTimeout are in seconds, 0 means no timeout