browserclaw 0.10.2 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3073,7 +3073,18 @@ function requiresInspectableBrowserNavigationRedirects(ssrfPolicy) {
3073
3073
  // src/actions/interaction.ts
3074
3074
  var MAX_CLICK_DELAY_MS = 5e3;
3075
3075
  var DEFAULT_SCROLL_TIMEOUT_MS = 2e4;
3076
- var CHECKABLE_ROLES = /* @__PURE__ */ new Set(["menuitemcheckbox", "menuitemradio", "checkbox", "switch"]);
3076
+ var CHECKABLE_ROLES = /* @__PURE__ */ new Set(["menuitemcheckbox", "menuitemradio", "checkbox", "radio", "switch"]);
3077
+ async function setCheckedViaEvaluate(locator, checked) {
3078
+ await locator.evaluate((el, desired) => {
3079
+ const input = el;
3080
+ const desc = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "checked");
3081
+ if (desc?.set) desc.set.call(input, desired);
3082
+ else input.checked = desired;
3083
+ input.dispatchEvent(new Event("input", { bubbles: true }));
3084
+ input.dispatchEvent(new Event("change", { bubbles: true }));
3085
+ input.click();
3086
+ }, checked);
3087
+ }
3077
3088
  function resolveLocator(page, resolved) {
3078
3089
  if (resolved.ref !== void 0 && resolved.ref !== "") return refLocator(page, resolved.ref);
3079
3090
  const sel = resolved.selector ?? "";
@@ -3248,8 +3259,12 @@ async function fillFormViaPlaywright(opts) {
3248
3259
  const checked = rawValue === true || rawValue === 1 || rawValue === "1" || rawValue === "true";
3249
3260
  try {
3250
3261
  await locator.setChecked(checked, { timeout, force: true });
3251
- } catch (err) {
3252
- throw toAIFriendlyError(err, ref);
3262
+ } catch {
3263
+ try {
3264
+ await setCheckedViaEvaluate(locator, checked);
3265
+ } catch (err) {
3266
+ throw toAIFriendlyError(err, ref);
3267
+ }
3253
3268
  }
3254
3269
  continue;
3255
3270
  }