High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix(cli): detect fill refs by numeric element id
zhaodf1bd366df9c6
diff --git a/internal/cli/actions/actions_element.go b/internal/cli/actions/actions_element.goindex a9084e28..0255d232 100644--- a/internal/cli/actions/actions_element.go+++ b/internal/cli/actions/actions_element.go@@ -10,6 +10,18 @@ import ("strings")+func isElementRef(value string) bool {+ if len(value) < 2 || value[0] != 'e' {+ return false+ }+ for i := 1; i < len(value); i++ {+ if value[i] < '0' || value[i] > '9' {+ return false+ }+ }+ return true+}+func Action(client *http.Client, base, token, kind, refArg string, cmd *cobra.Command) {body := map[string]any{"kind": kind}@@ -44,7 +56,7 @@ func ActionSimple(client *http.Client, base, token, kind string, args []string,body["ref"] = args[0]body["text"] = strings.Join(args[1:], " ")case "fill":- if strings.HasPrefix(args[0], "e") {+ if isElementRef(args[0]) {body["ref"] = args[0]} else {body["selector"] = args[0]diff --git a/internal/cli/actions/actions_element_test.go b/internal/cli/actions/actions_element_test.goindex 48a79bcc..b1b72dfa 100644--- a/internal/cli/actions/actions_element_test.go+++ b/internal/cli/actions/actions_element_test.go@@ -191,10 +191,21 @@ func TestFill(t *testing.T) {}ActionSimple(client, m.base(), "", "fill", []string{"#email", "[email protected]"}, cmd)+ body = nil_ = json.Unmarshal([]byte(m.lastBody), &body)if body["selector"] != "#email" {t.Errorf("expected selector=#email, got %v", body["selector"])}++ ActionSimple(client, m.base(), "", "fill", []string{"embed", "inline content"}, cmd)+ body = nil+ _ = json.Unmarshal([]byte(m.lastBody), &body)+ if body["selector"] != "embed" {+ t.Errorf("expected selector=embed, got %v", body["selector"])+ }+ if _, hasRef := body["ref"]; hasRef {+ t.Errorf("expected no ref for selector embed, got %v", body["ref"])+ }}func TestScroll(t *testing.T) {@@ -211,12 +222,14 @@ func TestScroll(t *testing.T) {}ActionSimple(client, m.base(), "", "scroll", []string{"800"}, cmd)+ body = nil_ = json.Unmarshal([]byte(m.lastBody), &body)if body["scrollY"] != float64(800) {t.Errorf("expected scrollY=800, got %v", body["scrollY"])}ActionSimple(client, m.base(), "", "scroll", []string{"down"}, cmd)+ body = nil_ = json.Unmarshal([]byte(m.lastBody), &body)if body["scrollY"] != float64(800) {t.Errorf("expected scrollY=800 for direction=down, got %v", body["scrollY"])