Forum Discussion

gita3632's avatar
gita3632
Contributor
15 years ago

A few short questions

Hi,



#1- How can I print to a log the individual values of any PROPERTIES of an OBJECT?



#2- what is the best way to compare/validate the contents of a multi line "innerText"   and also how can I  check to see if a specific string exists in in multi line "InnerText"



Example see the value of the follwoing inner text:







"Added to Cart


 

You've just added the following product to your cart


Some Kit

Item #:AAA

Quantity:1

Price:$13.00


 


Cart SummarySubtotal

Total Items in Cart:15

Merchandise Subtotal:$2,070.00


(Subtotal does not include shipping & processing, or tax)"


#3 -,  suppose if I have a popup page that contains the above info in a nice formatted web page what is the best approach to validate its data?  shall I use REGION Check point or use something like I suggested in Question#2 above?   This is assuming that the text and its values on the popup page are suppose to be the same.





Thanks

Gita

9 Replies

  • Hi,



    1. Just use the Log.Message method to post values of the needed properties.





    2. All scripting languages provide methods that allow you to check whether a string contains the needed text. See the "Working With Strings" help topic.



    3. You can use object or web comparison checkpoints to do this (see the "Object Checkpoints" and "Web Comparison Checkpoints" help topics).
  • Thanks Jared,  I heard that Object comparison is not a good I idea because it compares all the properties of the object and there are so many in there and if 1 changes the comparison will fail.  Is that a wrong statement?
  • Also 



     S = "Item #:UAWS

    Quantity:10

    Price:$138.00"



    the text was driven from the innerText properties.  why does it put a red X on line #1 
  • Also 



     S = "Item #:UAWS

    Quantity:10

    Price:$138.00"



    the text was driven from the innerText properties.  why does it put a red X on line #1 
  • Hi,



    You cannot break string constants to different lines this way. Here's the correct way to do this:

    S = "Item #:UAWS\r\n" +

    "Quantity:10\r\n" +

    "Price:$138.00"


    S = "Item #:UAWS" & vbCrLf &_

    "Quantity:10" & vbCrLf &_

    "Price:$138.00"

  • Awesome Jared.!!



    One more related question:  On the code below "loc1" shall not return '-1'  but it does!!

    I did a log message to see what is stored in i.innerText and surprisingly I see the entire object data and proberties rather than just the Value of innerText which is the same as in the string 'S' !!!  secondly even if  InnerText does not contain only the string specifies in 'S',  it still shall not return a '-1'  !     What am i missing here?



    Tx





    s = "Item #:UAWS\r\n" +


    "Quantity:4\r\n" +


    "Price:$138.00"


    loc1 = i.innerText.search(s);

  • Hi,



    Try using indexOf instead of search (the syntax will be the same, just the method name will change). If indexOf returns -1, try removing newline characters from the 'i.innerText' and 's':

    ...

    s = s.replace(/[\r\n]/g, "");

    txt = i.innerText.replace(/[\r\n]/g, "");



    if(txt.indexOf(s) > -1) //...

    ...

  • Thanks Jared ,  I will try that,    but still the main question remains as to why log.message( Object.innerText) shows the content and properties of the entire object rather then just the contents of innerText?





    Thanks

    Gita
  • Hi,



    The innerText property returns the text located in your object's node in the HTML source of your page. So, it will return all text which is out of HTML tags.

    If you need to obtain a value displayed in your object, try using other properties (for example, 'value').