如何解决如何在Selenium IDE中使用css = .ql-editor发布变量?
我试图生成一个随机数,然后使用该数字从数组中的3个字符串中选择1个进行发布。
我的变量是
${myArray[${myRandpost}]}
运行脚本时,我将变量作为字符串而不是变量内容获取
"${myArray[${myRandpost}]}"
不是
"string 1" or "string 2"
代码/脚本
{
"id": "4239032d-5701-46e0-a0fd-ef28921ffc0a","version": "2.0","name": "myFirst","url": "https://url.com","tests": [{
"id": "f72d0fdd-6ce6-4f20-bd20-264971ea8097","commands": [{
"id": "e2536619-fea6-4d85-8be5-f609d8a0ce85","comment": "","command": "open","target": "https://url.com/stuff/thread/5c6ba217562e40642d83b97b","targets": [],"value": ""
},{
"id": "e63fd61f-75e9-40ab-8542-ef766ba455ec","command": "setWindowSize","target": "550x692",{
"id": "5cfe9bde-b941-400c-89b8-2a4234a68f00","command": "runScript","target": "window.scrollTo(0,0)",{
"id": "f8d99537-e03a-465d-a635-1403e5a0a06f","command": "executeScript","target": "return [\"string 1",\"string 2",\"string 3"]","value": "myArray"
},{
"id": "b859b525-31c0-4c0e-94ab-0c3489d947c6","command": "store","target": "0","value": "x"
},{
"id": "c2b6ebd6-aa7f-4e08-b71d-c8c78ae62382","command": "while","target": "${x} <= 30000",{
"id": "6e5a9b89-3866-4f91-a80a-9753b541343b","comment": "generate a random number not to exceed MAXVALUE","target": "return Math.random() * 340000","value": "myRandomNumber"
},{
"id": "6f672425-cfa3-4aef-9043-40d223233bd2","comment": "generate a random number for post","target": "return Math.random() * 3","value": "myRandpost"
},{
"id": "d458800a-180b-42db-94df-5ef13fc02735","command": "echo","target": "${myRandomNumber}",{
"id": "4cb82fe0-6880-4796-983a-2d6c0f9c574b","target": "${myRandpost}",{
"id": "a15c50a7-7591-43c9-b448-18b8ba670451","target": "${x}+1",{
"id": "7c2c327a-1d49-455b-8293-ba462ed6e1d1","command": "click","target": "css=.ql-editor > p","targets": [
["css=.ql-editor > p","css:finder"],["xpath=//div[@id='chat_send-form_textarea']/div/div/p","xpath:idRelative"],["xpath=//div[2]/div[2]/div/div/div/p","xpath:position"]
],{
"id": "b08e956c-6d2d-4273-8757-fd33e893660a","command": "editContent","target": "css=.ql-editor","targets": [
["css=.ql-editor",["xpath=//div[@id='chat_send-form_textarea']/div/div",["xpath=//div[2]/div/div[2]/div[2]/div[2]/div/div/div","value": "${myArray[${myRandpost}]}"
},{
"id": "991161b8-2751-444e-ae96-40490debdc83","target": "css=.btn-filled","targets": [
["css=.btn-filled",["xpath=(//button[@type='button'])[5]","xpath:attributes"],["xpath=//div[@id='ember55']/div[2]/div[2]/div[3]/div[2]/button",["xpath=//div[3]/div[2]/button",{
"id": "52dc73e0-4690-4a3c-bfd3-30c80f734f6b",{
"id": "0549057d-bfb3-4320-a8de-bff8ea460c37","command": "pause",{
"id": "5fe597c8-43d8-4836-bbb4-742ba5a0fa1a","command": "end","target": "","value": ""
}]
}],"suites": [{
"id": "1efa2853-b50c-4492-89df-ef07e567e3b1","name": "Default Suite","persistSession": false,"parallel": false,"timeout": 300,"tests": ["f72d0fdd-6ce6-4f20-bd20-264971ea8097"]
}],"urls": ["https://url.com/"],"plugins": []
}
如何使用css = .ql编辑器发布变量内容?
更新:
日志输出
12:15:02
1.
open on https://url.com/chat/stuff/5c6ba217562e40642d83b97b OK
12:15:02
2.
setWindowSize on 550x692 OK
12:15:02
3.
runScript on window.scrollTo(0,0) OK
12:15:02
4.
executeScript on return ["string 1","string 2","string 3"] with value myArray OK
12:15:12
5.
store on 0 with value x OK
12:15:13
6.
while on ${x} <= 30000 OK
12:15:13
7.
executeScript on return Math.random() * 340000 with value myRandomNumber OK
12:15:13
8.
executeScript on return Math.random() * 3 with value myRandpost OK
12:15:13
echo: 54591.39046746507
12:15:13
echo: 2.583377180461124
12:15:13
11.
store on ${x}+1 OK
12:15:13
12.
click on css=.ql-editor > p OK
12:15:14
13.
editContent on css=.ql-editor with value ${myArray[${myRandpost}]} OK
12:15:14
14.
click on css=.btn-filled OK
12:15:14
15.
click on css=.btn-filled OK
12:15:14
16.
pause on ${myRandomNumber} OK
条目
12:15:13
echo: 2.583377180461124
看起来根本不正确。我的下一个问题是,如何删除精度?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。