Results 1 to 7 of 7

Thread: Checking Test

  1. #1

    Checking Test

    I'm testing a Web application (a mortgage calculation engine) and am checking the data input is being displayed correctly later on the application which is fine until I get to a line/row which has two variables on it with a big gap after the text. The Checkpoint Properties are this:

    Check that <Years> is displayed after Mortgage Term

    (Years is in red and is a parameter that I'm checking, Mortgage Term is in blue and is where the checkpoint is being displayed after. When I run the test I get the following:

    Text Checkpoint: captured "" after Mortgage term , expected "26"
    Match case: OFF
    Exact match: OFF
    Ignore spaces: OFF

    I thought the Ignore spaces would stop this from happening I've tried this On and Off but it still captures "0" - any tips?

  2. #2

    Re: Checking Test

    For a start, I hate checkpoints. I avoid them wherever possible. If the application changes you could wind up with a bunch of checkpoints that fail and you have to go through them one at a time and update them. I would much rather edit my datatable than have to update checkpoints.

    So my first thought is that you should probably capture this string into a variable.

    strMortgage = browser(a).page(b).object(c).GetROProperty("text")

    Then you can use the instr function to look within that string to find what you want.

    x = instr(strMortgage, "26")

    Then check to see if it worked. If 26 was found, x will be the numerical position within the string, otherwise x will be zero or null. Send a reportevent to the test results log to indicate pass/fail.

    if x > 0 then
    reporter.reportevent micPass, "Check Term", "Term 26 years was found at position " & x
    reporter.reportevent micFail, "Check Term", "Term 26 years was not found"
    end if

    My next suggestion would be to parameterize your term if you feel the need. Maybe you will want to run this test multiple times with different terms, so you create rows in the datatable containing all your expected inputs/outputs and use that data throughout your test.

    Even if you don't ever do that, you may find a time when your application changes and, for example, what used to be 26 years is now 624 months and this test fails. Easier to update your datatable than to scan through all the script and make changes to hard-coded values.

    So change it to:

    strTerm = datatable("Expected_Term") 'whatever you call the name of the column that has the value 26

    strMortgage = browser(a).page(b).object(c).GetROProperty("text")

    x = instr(strMortgage, strTerm)

    if x > 0 then
    reporter.reportevent micPass, "Check Term", "Term " & strTerm & " years was found at position " & x
    reporter.reportevent micFail, "Check Term", "Term " & strTerm & " years was not found"
    end if

    Hope that helps.


  3. #3

    Re: Checking Test

    Thanks this is great and that would have solved the issue except that when I spy on the Object it actually contains both variables that I need to check for (and yes I much prefer using data tables and wholeheartedly agree).

    Using your code is there anyway to segregate the following:

    27 years and 3 months, the numbers being the variables. in other words I want to just have the following in the data table <years> and <months> as two seperate entries and perform two seperate checks. Sorry, I know I should be able to work this out but I don't know how to sepearate the two variables.



  4. #4

    Re: Checking Test

    I am not sure what your screen looks like. I am assuming that when you spy on the object, the "text" property of that object looks something like: "Mortgage Term: 27 years and 3 months."

    You don't actually have to split that text. The code I posted above should work fine.

    strMortgage = browser(a).page(b).object(c).GetROProperty("text")
    x = instr(strMortgage, "27")
    y = instr(strMortgage, "3")

    This should return a value of 18 to the variable x and a value of 31 to the variable y.

    The other stuff I posted shows you how to report the pass/fail and how to parameterize it so you can check for any value.

    There is a challenge to be overcome. If the string is "Mortgage Term: 27 years and 2 months." then both x and y will be 18 which is a problem.

    This can be overcome as follows:

    x = instr(strMortgage, "27 years")
    y = instr(strMortgage, "2 months")

    Or if parameterized:

    x = instr(strMortgage, strTerm & " years")
    y = instr(strMortgage, strTerm & " months")

    Which will make the instr function search for "27 years" and search for "2 months" instead of just searching for the numbers alone.


  5. #5

    Re: Checking Test

    Note that you should be able to create functions to parse the contents of variable strings, such that you can refer to yr and mo instead, as well as use variables that contain the valid argument to compare with. You can then reuse these same functions in future testing, to simplify your life and to reduce the script maintenance effort.
    Frits Bos, PMP

  6. #6
    Junior Member
    Join Date
    Mar 2002

    Re: Checking Test

    I totally agree with Walker. I too avoid checkpoints as much as I can. String manipulations after getting through RO property solves many of these issues. Thanks to walker again to bring this to the forefront.
    Suswaram Radha

  7. #7

    Re: Checking Test

    thanks it works great now, I've extracted the numerics into two variables using years and months and then done a compare to the whole text line e.g.

    stryears + 'Years' strmonths + 'months'

    and then ran a compare and this worked a treat, I've also found out that using the Checktext functionality you can output the text to a table and then do the compare via excel on the table to the two input variables to check that the data input matches the data output.

    I really appreciate the time that people put into these forums and hope to be able to help others later - thanks in particular Mr Walker



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:54 PM.

Copyright BetaSoft Inc.