SeleniumHQ / selenium-ide

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

text data detected as Json #745

Open adrien-ber opened 5 years ago

adrien-ber commented 5 years ago

🐛 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

eli-hu commented 1 year ago

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.

toddtarsi commented 1 year ago

@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 🙂

YecineM commented 1 year ago

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

toddtarsi commented 1 year ago

@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'

YecineM commented 1 year ago

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

toddtarsi commented 1 year ago

@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.

YecineM commented 1 year ago
{
  "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": []
}