selenium-ide icon indicating copy to clipboard operation
selenium-ide copied to clipboard

text data detected as Json

Open adrien-ber opened this issue 6 years ago • 7 comments

🐛 Bug Report

I can store text, but i cant reuse it after because of <:> or <"> when i use "store text" from an xpath element or "store" instruction who contain <<Your customer number : "3789". >> I cant do "execute script" to split it or

executeScript on return ${Cnumber}.split('"')[1] with value Cnumber Failed:16:28:05 JSON.parse: expected ',' or ']' after array element at line 1 column 27 of the JSON data

To Reproduce

{ "id": "66c3fbd1-c976-4fb9-a9af-c0cae51230df", "comment": "", "command": "store", "target": "Your customer number : "3789". ", "targets": [], "value": "Cnumber" }, { "id": "623c0981-16d1-42e2-b5e4-75d75c9edad6", "comment": "", "command": "echo", "target": "${Cnumber}", "targets": [], "value": "" }, { "id": "d387fd35-cd87-40ad-8257-c86df180b9ea", "comment": "", "command": "executeScript", "target": "return ${Cnumber}.split('"')[1]", "targets": [], "value": "Cnumber" }

OS: Windows 7 Selenium IDE Version: Browser: firefox

adrien-ber avatar Jul 17 '19 14:07 adrien-ber

I have the same problem. My text is ["In Copyright"] including the square brackets and quotation marks, and I'm getting Failed: JSON.parse: expected ',' or ']' after array element at line 1 column 5 of the JSON data when I try to use the value in if or execute script.

eli-hu avatar Sep 21 '22 20:09 eli-hu

@eli-hu - I'm not really fixing v3 anymore, but if you can provide a clear reproduction of this in v4, I'll go after it 🙂

toddtarsi avatar Sep 21 '22 21:09 toddtarsi

It looks interesting.. So V3 projects may not work on Selenium IDE V4 ?

YecineM avatar Sep 22 '22 20:09 YecineM

@YecineM - Compatibility should work for everything except plugins. Plugins will require some work unfortunately, but most of that will be removing all of the complexities of making webextensions 'talk'

toddtarsi avatar Sep 22 '22 23:09 toddtarsi

This issue may not be a priority, but here's a reproduction that should work in V4.

YecineM avatar Sep 23 '22 13:09 YecineM

@YecineM - Providing a reproducing test is next to godliness. If you've done the hard work to simplify the issue, the least I can do is attempt to follow it up.

toddtarsi avatar Sep 23 '22 14:09 toddtarsi

{
  "id": "450bde44-2af9-4596-8e66-6c893a4803ff",
  "version": "2.0",
  "name": "example",
  "url": "/",
  "tests": [{
    "id": "87537416-d9e6-4b31-8599-46e804272a0a",
    "name": "Untitled",
    "commands": [{
      "id": "0358abcc-0821-4565-a4cf-1a818a3886d9",
      "comment": "",
      "command": "open",
      "target": "https://html.com/tags/br/",
      "targets": [],
      "value": ""
    }, {
      "id": "62659d39-3163-4d29-bb84-c6635c9f591e",
      "comment": "",
      "command": "storeText",
      "target": "css=.post-single > .render",
      "targets": [
        ["css=.post-single > .render", "css:finder"],
        ["xpath=//article[@id='post-69']/div/div[4]", "xpath:idRelative"],
        ["xpath=//div/div[4]", "xpath:position"]
      ],
      "value": "str"
    }, {
      "id": "ebdbc59d-11a2-46e9-9aa6-7dbd92800885",
      "comment": "",
      "command": "echo",
      "target": "${str}",
      "targets": [],
      "value": ""
    }, {
      "id": "782b147a-e77c-4066-8e5c-faeaa65d00b8",
      "comment": "",
      "command": "if",
      "target": "${str}==\"\"",
      "targets": [],
      "value": ""
    }, {
      "id": "b003bdb3-dd9a-4dbe-972d-6ea0e640447e",
      "comment": "",
      "command": "echo",
      "target": "nothing",
      "targets": [],
      "value": ""
    }, {
      "id": "f321db52-0a6d-42e9-a82f-bcc1cd8d5c43",
      "comment": "",
      "command": "end",
      "target": "",
      "targets": [],
      "value": ""
    }]
  }],
  "suites": [{
    "id": "c1e93f4f-fd9f-471d-9c4c-cec4aaab875c",
    "name": "Default Suite",
    "persistSession": false,
    "parallel": false,
    "timeout": 300,
    "tests": ["87537416-d9e6-4b31-8599-46e804272a0a"]
  }],
  "urls": [],
  "plugins": []
}

YecineM avatar Sep 27 '22 16:09 YecineM