Selenium IDE:无法记录来自自定义Web扩展的自定义命令。

huangapple go评论76阅读模式
英文:

Selenium IDE : Can't record custom command from custom WebExtension

问题

我正在尝试使用我自制的插件添加一些自定义命令,就像文档中所说的那样:https://www.selenium.dev/selenium-ide/docs/en/plugins/plugins-getting-started

它运行正常,我正在注册我的插件和命令,如下所示:

const registerPayload = {
    uri: "/register",
    verb: "post",
    payload: {
        name: "InterceptPOC",
        version: "1.0",
        commands: [
            {
                id: "threeJsCommand",
                name: "ThreeJS Action"
            }
        ]
    }
};

chrome.runtime.sendMessage("mooikfkahbdckldjjndioackbalphokd", registerPayload);

我可以在我的IDE上看到我的命令:

Selenium IDE:无法记录来自自定义Web扩展的自定义命令。

但是,当我尝试在录制时执行POST请求时,使用以下代码:

const requestPayload = {
    uri: "/record/command",
    verb: "post",
    command: "threeJsCommand",
    target: "test"
}

chrome.runtime.sendMessage("mooikfkahbdckldjjndioackbalphokd", requestPayload);

我只能看到一个空的注释命令在我的录制中:

Selenium IDE:无法记录来自自定义Web扩展的自定义命令。

我尝试添加一个"click"命令,结果是相同的:空的注释行,而不是点击命令。

我是否做错了什么?我在互联网上找不到示例。谢谢。

英文:

I'm trying to add some custom command using my homemade plugin like the documentation say we can: https://www.selenium.dev/selenium-ide/docs/en/plugins/plugins-getting-started

It is working fine, I am registering my plugin with my command like that

const registerPayload = {
        uri: "/register",
        verb: "post",
        payload: {
          name: "InterceptPOC",
          version: "1.0",
          commands: [
            {
              id: "threeJsCommand",
              name: "ThreeJS Action"
            } 
            ]
        }
      };

      chrome.runtime.sendMessage("mooikfkahbdckldjjndioackbalphokd", registerPayload);

And I can see my command on my IDE :

Selenium IDE:无法记录来自自定义Web扩展的自定义命令。

But when I try to do a POST when I record, with

const requestPayload = {
        uri: "/record/command",
        verb: "post",
        command: "threeJsCommand",
        target: "test"
      }

      chrome.runtime.sendMessage("mooikfkahbdckldjjndioackbalphokd", requestPayload);

And all I can see is an empty commented command in my record :
Selenium IDE:无法记录来自自定义Web扩展的自定义命令。

I tried to add a "click" command and I had the same behaviour : empty commented line, not the click command.

Am I doing something wrong ? I am having a lot of trouble to find exemple on the internet.

Thanks

答案1

得分: 0

如果有其他人遇到了这个问题,请注意文档在2023年01月08日是错误的。

Todd Tarsi在这里用正确的片段帮助了我:https://github.com/SeleniumHQ/selenium-ide/issues/1683

const writeSucceeded = await browser.runtime.sendMessage(seleniumIDEExtension, {
  uri: "/record/command",
  verb: "post",
  payload: {
    command: "writeToDraftJS",
    target: 'css=.asdf',
    value: 'asdf',
  },
});
英文:

If someone else has the issue, please not that the documentation was wrong at the 01/08/2023.

Todd Tarsi here helped me with a correct snippet : https://github.com/SeleniumHQ/selenium-ide/issues/1683

const writeSucceeded = await browser.runtime.sendMessage(seleniumIDEExtension, {
  uri: "/record/command",
  verb: "post",
  payload: {
    command: "writeToDraftJS",
    target: 'css=.asdf',
    value: 'asdf',
  },
});

huangapple
  • 本文由 发表于 2023年7月31日 23:41:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76805165.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定