如何使用浏览器。

发布于 2025-02-12 07:35:28 字数 796 浏览 0 评论 0原文

有人知道需要对此代码进行哪些调整才能在Firefox上正确执行?

这是我的测试代码,它可以执行控制 +单击Chrome上的项目。但是,当在Firefox上执行(Geckodriver V0.30.0 Win64)时,测试代码的效果变成单击项目。我检查了doc https://webdriver.io/docs/docs/docs/api/webdriver/webdriver/webdriver/#performions < /a>,但找不到任何线索。

const ctlKey = '\uE009';  
browser.performActions([
    {
      actions: [{ type: 'keyDown', value: ctlKey }],
      id: 'press',
      type: 'key',
    },
  ]);

  // multiple Control + Click.
  items.forEach(item => {
    item.click();
  });

  // release
  browser.performActions([
    {
      actions: [{ type: 'keyUp', value: ctlKey }],
      id: 'release',
      type: 'key',
    },
  ]);

Does anyone know what adjustments need to be made to this code to execute correctly on FireFox?

Here is my test code, it can execute Control + Click items on chrome. But when executed on FireFox(geckodriver v0.30.0 win64), the effect of the test code becomes Click items. I checked the doc https://webdriver.io/docs/api/webdriver/#performactions, but not found any clue.

const ctlKey = '\uE009';  
browser.performActions([
    {
      actions: [{ type: 'keyDown', value: ctlKey }],
      id: 'press',
      type: 'key',
    },
  ]);

  // multiple Control + Click.
  items.forEach(item => {
    item.click();
  });

  // release
  browser.performActions([
    {
      actions: [{ type: 'keyUp', value: ctlKey }],
      id: 'release',
      type: 'key',
    },
  ]);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满身野味 2025-02-19 07:35:28

看起来Firefox无法以这种方式支持。仅当我使用表演与按下和释放控件一起进行单击时,它才能起作用。

const clickActions = [
    {
      actions: [
        {
          duration: 0,
          type: 'pointerMove',
          x: Math.floor(item.x),
          y: Math.floor(item.y),
        },
        { duration: 200, type: 'pause' },
        { button: 0, type: 'pointerDown' },
        { duration: 200, type: 'pause' },
        { button: 0, type: 'pointerUp' },
      ],
      id: 'click_item_1',
      parameters: { pointerType: 'mouse' },
      type: 'pointer',
    },
    ...// more clicks
];
let allActions = [];

allActions.push({
    actions: [{ type: 'keyDown', value: '\uE009' }],
    id: 'hold_ctrl',
    type: 'key',
});

allActions = allActions.concat(clickActions);

allActions.push({
    actions: [{ type: 'keyUp', value: '\uE009' }],
    id: 'release_ctrl',
    type: 'key',
});
browser.performActions(allActions);

It looks like FireFox can't support this way. It only works when I use performActions to do clicks together with pressing and releasing the Control.

const clickActions = [
    {
      actions: [
        {
          duration: 0,
          type: 'pointerMove',
          x: Math.floor(item.x),
          y: Math.floor(item.y),
        },
        { duration: 200, type: 'pause' },
        { button: 0, type: 'pointerDown' },
        { duration: 200, type: 'pause' },
        { button: 0, type: 'pointerUp' },
      ],
      id: 'click_item_1',
      parameters: { pointerType: 'mouse' },
      type: 'pointer',
    },
    ...// more clicks
];
let allActions = [];

allActions.push({
    actions: [{ type: 'keyDown', value: '\uE009' }],
    id: 'hold_ctrl',
    type: 'key',
});

allActions = allActions.concat(clickActions);

allActions.push({
    actions: [{ type: 'keyUp', value: '\uE009' }],
    id: 'release_ctrl',
    type: 'key',
});
browser.performActions(allActions);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文