I selected a column from a grid and trying to create a within assertion using the innerText value. Testing the assertion and running the test give an error about the value not being a number. How do I use the within, greater than, 'less than' assertions and have the value to be treated as a number in Studio? Looking for something like parseInt.
Also the generated JS doesn't look right. I don't see the end value of 50.
It is impossible to use strings obtained from HTML in the `within` and `without` commands
Answers approved by DevExpress Support
We have addressed the issue described in this ticket and will include a fix in our next maintenance update. Should you need to apply our fix prior to official release, you can request a hotfix here.
Important Notes:
- Hotfixes may be unavailable for Early Access/Beta builds or updates set for release within a week.
- .NET only: in the NuGet Package Manager, use your personal NuGet feed and check the "Include prerelease" option to view the hotfix package in the "Updates" tab.
Hello,
There is currently no built-in ability to cast strings to numbers inside assertions in codeless tests. There are two ways to get around this: use coded tests or custom scripts blocks. In any case, your code should be like this:
JavaScriptconst str = await Selector('td').withText('1.45').innerText;
await t.expect(Number(str)).within(2, 50);
As for the error in converting to JS, this is a bug. Thank you for letting us know about it.
Thanks.
Please add a feature where we can convert strings to numbers in the codeless tests so that they can be used in these types of assertions. It's common to have textboxes, labels and columns in html tables to contain numbers. Using innerText or textContent or value properties of selected elements seem to always return strings in my tests.
Hello,
I have already created a corresponding issue in our repository. Unfortunately, I cannot say how soon we will be able to introduce this feature. We will update this ticket once we have results.
Hi,
We fixed a bug with incorrect conversion of the within
and without
commands.
Also, we have written a task to improve the work of these commands so that they can take values received from html elements.