Bug Report T1087688
Visible to All Users

It is impossible to use strings obtained from HTML in the `within` and `without` commands

created 3 years ago

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.

Answers approved by DevExpress Support

created 3 years ago

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.
    created 3 years ago

    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:

    JavaScript
    const 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.

      Comments (3)

        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.

        DevExpress Support Team 3 years ago

          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.

          DevExpress Support Team 3 years ago

            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.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.