compare two values in ranorex

2019-07-31 10:37发布

问题:

We are using Ranorex 5.02 We need to compare values (numbers) in website UI and generated pdf file these values always are the same. Each time the system will generate new values for UI and pdf file. We need to check that the new generated values are correct. Adding validation methods not really help because the system recorded actual number and after running test script again validation is failed. We tried to create variables in validations the system displays unbounded variable message.

Any help is greatly appreciated.

回答1:

You can use the "Get Value" action in order to store the values into a variable. After that you can compare the values using the "Equals" method from the String class in .NET.

 public void CompareText(string webText, string pdfText)
    {
        if(webText.Equals(pdfText))
        {
            Report.Info("Text is equal!");
        }
        else
        {
            Report.Info("Text is NOT equal!");
        }
    }