英文:
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上看到我的命令:
但是,当我尝试在录制时执行POST请求时,使用以下代码:
const requestPayload = {
uri: "/record/command",
verb: "post",
command: "threeJsCommand",
target: "test"
}
chrome.runtime.sendMessage("mooikfkahbdckldjjndioackbalphokd", requestPayload);
我只能看到一个空的注释命令在我的录制中:
我尝试添加一个"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 :
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 :
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',
},
});
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论