Visual Studio 2012 - Coded UI Test Builder: Assertion Formula? -


while automating testing of website shopping experience, attempting verify subtotal, total, , tax calculating properly. since price and/or tax change in future, cannot assert actual price value inside control. instead, need build calculation based upon controls , assert quantity multiplied individual price each item added equals subtotal, , on.

for example, controls each named such (control names in asterisks):

 quantity = *uiitem2cell*  (innertext has value of 2)   individual price = *uiitem249pane*  (displaytext has value of 2.49)   individual product total (price x qty) = *uiitem498pane*  (innertext has value of 4.98) 

instead of validating values actual numbers, can write assertion formula using identifiers variables?

keep in mind, using coded ui test builder rather writing code outright.

if individual product total innertext assertion comparator areequal, can comparison value like:

 uiitem2cell-innertext * uiitem249pane-displaytext 

a. sort of formula possible?

b. if so, how write it?

(please forgive me, green when comes this.)

you can. first off in app useful use ids on controls can match on criteria. way not using calculated values search criteria.

now in question need pull values cells, calculate value , use in search criteria

// i'd recommend trimming text values:  // depending on how tables , such rendered you'll have white-space characters var firstvalue = double.parse(uiitem2cell.innertext.trim()); var secondvalue = double.parse(uiitem249pane.displaytext.trim()); var calculatedvalue = string.format("{0,n2}%", firstvalue * secondvalue);  // assuming in web app var totaldiv = new htmldiv(currenthtmldoc); totaldiv.searchproperties.add(new propertyexpression(htmldiv.propertynames.innertext, calculatedvalue, propertyexpressionoperator.contains)); assert.istrue(totaldiv.tryfind()); sringassert.contains(totaldiv.innertext,calculatedvalue); 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -