Search code examples
selenium-webdriverselenium-ideweb-extension

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


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 :

enter image description here

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 : enter image description here

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


Solution

  • 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',
      },
    });