SeleniumHQ / selenium-ide

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

selenium-side-runner does not access object value. #1603

Open stxm opened 1 year ago

stxm commented 1 year ago

🐛 Bug Report

selenium-side-runner does not access object value. The type action type literally ${i.foo} The code below works ok in the selenium IDE, but not on side runner. Moreover, I have noticed that the export to pytest has trouble processing too.

Possibly related to #1158

self.driver.find_element(By.NAME, "q").send_keys("${i.foo}")
info: Driver has been built for firefox
debug: Playing state changed playing for test bug
debug: executing open
debug: passed open
debug: executing storeJson|[{"foo":"bar"}]|mydata
debug: passed storeJson|[{"foo":"bar"}]|mydata
debug: executing forEach|mydata|i
debug: passed forEach|mydata|i
debug: executing type|name=q|${i.foo}
debug: passed type|name=q|${i.foo}
debug: executing echo|${i.foo}
info: echo: ${i.foo}
debug: passed echo|${i.foo}
debug: executing forEach|mydata|i
debug: passed forEach|mydata|i
debug: executing end
debug: passed end
debug: executing assertValue|name=q|bar
  console.warn
    Unexpected error occured during command: assertValue-name=q-bar retrying...

      at CommandNode.handleTransientError (node_modules/@seleniumhq/side-runtime/src/playback-tree/command-node.ts:185:15)
      at CommandNode.retryCommand (node_modules/@seleniumhq/side-runtime/src/playback-tree/command-node.ts:161:12)
      at CommandNode.execute (node_modules/@seleniumhq/side-runtime/src/playback-tree/command-node.ts:100:20)
      at Playback._executeCommand (node_modules/@seleniumhq/side-runtime/src/playback.ts:555:22)
      at Playback._executionLoop (node_modules/@seleniumhq/side-runtime/src/playback.ts:437:18)
      at Playback._executionLoop (node_modules/@seleniumhq/side-runtime/src/playback.ts:491:14)

  console.error
    Actual value '${i.foo}' did not match 'bar'

To Reproduce

Steps to reproduce the behavior:

    # Test name: bug
    # Step # | name | target | value
    # 1 | open | https://duckduckgo.com | 
    # 2 | storeJson | [{"foo":"bar"}] | mydata
    # 3 | forEach | mydata | i
      # 4 | type | name=q | ${i.foo}
      # 5 | echo | ${i.foo} | "${i.foo}"
      # 6 | end |  | 
    # 7 | assertValue | name=q | bar

Expected behavior

I expect the same behavior as Selenium IDE

1.open on https://duckduckgo.com/ OK
2.storeJson on [{"foo":"bar"}] with value mydata OK
3.forEach on mydata with value i OK
4.type on name=q with value ${[i.foo](http://i.foo/)} OK
echo: bar
6.end OK
7.assertValue on name=q with value bar OK

Project file reproducing this issue (highly encouraged)

{
  "id": "2e293e80-7acd-4969-858a-0f439fe47dfa",
  "version": "2.0",
  "name": "reproduce",
  "url": "https://duckduckgo.com",
  "tests": [{
    "id": "313b6ef7-6640-49cf-9524-8d0a1c174212",
    "name": "bug",
    "commands": [{
      "id": "c63bb04a-24ef-4858-ae77-f443bfc38588",
      "comment": "",
      "command": "open",
      "target": "",
      "targets": [],
      "value": ""
    }, {
      "id": "13f668ef-84b4-4356-ac02-503942eb1885",
      "comment": "",
      "command": "storeJson",
      "target": "[{\"foo\":\"bar\"}]",
      "targets": [],
      "value": "mydata"
    }, {
      "id": "e7660f1f-44d2-4ccf-8088-2a4c8dce5485",
      "comment": "",
      "command": "forEach",
      "target": "mydata",
      "targets": [],
      "value": "i"
    }, {
      "id": "ec4655ab-d4cf-4176-ba48-632619ba284c",
      "comment": "",
      "command": "type",
      "target": "name=q",
      "targets": [
        ["id=searchbox_input", "id"],
        ["name=q", "name"],
        ["css=#searchbox_input", "css:finder"],
        ["xpath=//input[@id='searchbox_input']", "xpath:attributes"],
        ["xpath=//form[@id='searchbox_homepage']/div/input[3]", "xpath:idRelative"],
        ["xpath=//input[3]", "xpath:position"]
      ],
      "value": "${i.foo}"
    }, {
      "id": "18b1d08e-3975-4453-ab54-e97ccab7fccf",
      "comment": "",
      "command": "echo",
      "target": "${i.foo}",
      "targets": [],
      "value": ""
    }, {
      "id": "96c29a71-63b4-40f1-8ce1-e40bd3ba203b",
      "comment": "",
      "command": "end",
      "target": "",
      "targets": [],
      "value": ""
    }, {
      "id": "733bdd95-0ab7-4fcc-9865-4430b151b144",
      "comment": "",
      "command": "assertValue",
      "target": "name=q",
      "targets": [
        ["id=searchbox_input", "id"],
        ["name=q", "name"],
        ["css=#searchbox_input", "css:finder"],
        ["xpath=//input[@id='searchbox_input']", "xpath:attributes"],
        ["xpath=//form[@id='searchbox_homepage']/div/input[3]", "xpath:idRelative"],
        ["xpath=//input[3]", "xpath:position"]
      ],
      "value": "bar"
    }]
  }],
  "suites": [{
    "id": "46903feb-0e08-4ec6-a4cb-93b38a72dc4c",
    "name": "bug",
    "persistSession": false,
    "parallel": false,
    "timeout": 300,
    "tests": ["313b6ef7-6640-49cf-9524-8d0a1c174212"]
  }],
  "urls": ["https://duckduckgo.com/"],
  "plugins": []
}

Environment

OS: Linux Selenium IDE Version: 3.17.2 Selenium SIDE Runner Version: 4.0.0-alpha.43 Node version: 18 Browser: Firefox Browser Version: Mozilla/5.0 (Windows NT 10.0; rv:111.0) Gecko/20100101 Firefox/111.0

lesanges commented 2 months ago

Still unresolved on Apr, 19 2024 Makes it really awkward to run automated test

OS : linux Selenium IDE Version: 3.17.4 Selenium SIDE Runner Version: 4.0.4 Node version: 19.9.0 Browser: Firefox Browser Version: Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0