SeleniumHQ / selenium-ide

Open Source record and playback test automation for the web.
https://selenium.dev/selenium-ide/
Apache License 2.0
2.8k stars 762 forks source link

SeleniumIDE can't receive payload of record command from external WebExtension #1683

Closed vbaulac closed 1 year ago

vbaulac commented 1 year ago

Hello,

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 : image

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);

I do receive something, but it is blank and commented. image

I tried sending a simple "click" command, and I receive the same : a blank commented line, like if SIDE do not recognize the payload that I am sending him. However, the payload I send is the one describe in the documentation.

Is this a known issue ?

Thanks

toddtarsi commented 1 year ago

There you are! I saw your message from IRC and responded after an hour, but I think I was bit too late. Reposting!

@vbaulac - I basically do this any time a site I’m working with uses content editables. This is a snippet from how I replace ‘edit content’ with a custom ‘writeToDraftJS’ command.

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

Also, there’s a channel on slack ‘selenium_ide’. It's not IRC, but slack, so no Matrix integration and things tend to last forever there. Feel free to reach out there or here as both are persisted so I can get to em before/after work

vbaulac commented 1 year ago

Yay ! Thank you very much for your input, it works now !

The documentation is wrong/deprecated for the payload : https://www.selenium.dev/selenium-ide/docs/en/api/plugins/record

This is why I was in trouble sending the correct data. I don't know if I can warn someone to update it ? Or do it myself ;)

Thanks !

toddtarsi commented 1 year ago

@vbaulac - Honestly, I don't know how much longer v3 will work with the manifest changes (as far as I know, they're completely incompatible with commands like assert and execute-script). v4 is in version .45 here and is getting pretty stable:

https://github.com/SeleniumHQ/selenium-ide/releases/tag/4.0.0-alpha.45

Remaining items are adding a few more plugin capabilities around custom menu entries, using the example side files to test the ide and not just the side-runner, and adding a doc site or a github wiki or something.

That said, I think you'll have a much better experience writing plugins for this than the web extension model. Focusing on just plugins, there are the following advantages:

  1. It's typed.
  2. Plugins support anything that NodeJS require() can find basically, so writing and sharing plugins just requires publishing an npm package instead of a webextension.
  3. It supports project level plugins, so you can bundle side files and plugins in a single git repo.

There's a litany of other big pickups too, but those aren't relevant here.

toddtarsi commented 1 year ago

Oh, for point 2, you can also just have a js file for your plugin and the path to it from your project. Npm isn't required either. It's just meant to be a pain free way to open source stuff for other people.

toddtarsi commented 1 year ago

Also, that said, I'd give it one or two more weeks before you write any plugins for it. I'm basically adding those addl capabilities this week, so after this weekend, the @seleniumhq/side-api package is meant to be the one stop shop for all of your plugin writing needs. And then the next weekend, I'll start breaking ground on a github wiki or something so you've got some companion docs.

vbaulac commented 1 year ago

Ok thanks for infos ! I did not realize there was a big change incoming. So far I am just building a POC of a solution for our testing issues. So the final solution will be in v4, with all the advantages of it ;)

Looking forward for your wiki !

toddtarsi commented 1 year ago

@vbaulac - Closing this issue. Please open any more for anything you encounter. Thanks!

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.