selenium-ide
selenium-ide copied to clipboard
Allow plugin to access variables
🚀 Feature Proposal
The plugin support should allow plugins to access variables.
Motivation
My plugin collects data during the test which the test author might like access to. If I could access variables, then I could implement a store data command.
Example
My plugin allows test authors to measure the duration of events. If I could store a result in a variable, then the test author could use assert to fail a test if the site is too slow.
Does the absence of this feature mean that it is impossible for a custom command to pass information back to the IDE to be used in other commands? Is there any work around?
Plugins can set a variable, but they can't ask selenium IDE for the value, we should add a getter.
Sorry for polluting this issue, but is there docs on setting? I'm struggling to find them.
I don't see one either. We'll need to add it.
Do you mean just that the documentation is missing, but the functionality is present? If so, can you point me in the right direction for getting this working? Thanks.
browser.runtime.sendMessage(seleniumExtId, {
uri: "/playback/var",
verb: "put",
payload: {
name: "my_var",
contents: "value of var"
}
})
.then(() => sendResponse(true))
.catch(console.error);
return true;
Would be great to get documentation on this page.
Yes, that's the one. I'll get it added to the docs.
@tourdedave @darichey @corevo can anyone of you please post a working example. So I successfully added a chrome plugin, my plugin is visible in command list of selenium ide, When I select my command and run, it returns a proper value but I am unable to stored that returned value in variable. So can you please advice me how to achieve this. Here I attach my background.js and manifest.json for reference. Your response will be appreciated. Thanks!
You can't put a variable unless a playback started, your code tries to do it even before the plugin registered.
@corevo Thanks a lot for your prompt response, So as per your suggestion, I have made changes to my script file and now I am adding variable after playback started. But now I am getting "Selenium IDE: Unable to add variable fname" error. For your reference I have attached my script file. Thanks!
Same problem for me. I'am also getting "Selenium IDE : Unable add variable xxx" error.
From the code reference shared by @darichey , looks like the put
fails if the contents is not a valid JSON. That means the variable needs to be a Object rather a String, which makes it more par to store JSON command, rather than just plain store.
browser.runtime.sendMessage(seleniumExtId, { uri: "/playback/var", verb: "put", payload: { name: "my_var", contents: "value of var" } }) .then(() => sendResponse(true)) .catch(console.error); return true;
Would be great to get documentation on this page.
The below code works but is there a way to put raw String instead of JSON? Checking if any variable getters were added anytime recently?
browser.runtime.sendMessage(seideId, {
uri: "/playback/var",
verb: "put",
payload: {
name: "var1",
contents: "{\"complex\" : \"varObject\"}"
}
}).then(() => {
console.log("Successfully added variable.")
}).catch(console.error);
@pratikritwick - Because of the basically insurmountable permission changes of Manifest v3, nobody has committed anything to v3 in a while. It's pretty darn near end of life. V4 is under development as an electron binary here:
https://github.com/SeleniumHQ/selenium-ide/releases/tag/4.0.0-alpha.56
If neither of those appeal to you, I'd recommend the nightwatch js browser extension for the chrome devtools recorder.