selenium-ide
selenium-ide copied to clipboard
Unable to test for the newline string: \n
🐛 Bug Report
Unable to test for the newline string: \n
To Reproduce
- Web app generates this response:
<code id="command">\n</code> - Selenium IDE tests:
command:assert text, target:id=command value:\n - Assertion fails with
Actual value "\n" did not match " "
Expected behavior
OK response, because \n matches \n
Project file reproducing this issue
{
"id": "78afc19d-4337-4325-b6ca-606ebc608247",
"version": "2.0",
"name": "possible-bug",
"url": "http://192.168.1.26/test",
"tests": [{
"id": "2ad05271-a621-4a77-991e-1436c22718c9",
"name": "Newline Test",
"commands": [{
"id": "5828e260-1800-4131-974a-06331729922e",
"comment": "",
"command": "open",
"target": "http://192.168.1.26/test",
"targets": [],
"value": ""
}, {
"id": "f6a18dc1-b423-47db-a538-72ed362073ed",
"comment": "",
"command": "assertText",
"target": "id=command",
"targets": [],
"value": "\\n"
}]
}],
"suites": [{
"id": "f58effac-b034-4dd1-8032-74fcef202353",
"name": "Default Suite",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["2ad05271-a621-4a77-991e-1436c22718c9"]
}],
"urls": ["http://192.168.1.26/test"],
"plugins": []
}
Additional Notes
This is my index.php file:
<?php echo '<code id="command">\n</code>'; ?>
I've tried escaping it every way I can think but it appears that \n takes precedence and is always converted into a newline character. Presumably, this allows Selenium to actually test for a newline (ascii 10) in the test output (which is good). But that also means this string cannot be tested. Attempting to escape it \\n only results in a single backslash + newline character rather than the literal string \n.
Environment
OS: Windows 10 Selenium IDE Version: 3.17.2 Browser: Chrome Browser Version: Version 99.0.4844.74 (64 bit)
@celdaran - Thank you for reporting! We're currently bearing down on releasing a major rewrite, so we're not going after these issues in the immediate term. We expect to be releasing an alpha in the next couple weeks, and then will be coming back around to these types of issues. Thank you for reporting!
Also, great catch! This is a bit of an uncommon use case, as we're used to users checking for certain word style patterns, but we certainly should do our best to account for it. Thanks for reporting.
@toddtarsi - Thanks for the quick reply. Looking forward to what's up and coming.
In the meantime (for anyone else having this issue) I've added an environment-aware hack to my code that will flip backslashes to forward slashes, solely for this type of testing. It's good enough for repeatable tests and can be disabled for actual functioning outside of testing.
@celdaran how did you achieve that?