You are on page 1of 16

/* * Copyright 2004 ThoughtWorks, Inc * * Licensed under the Apache License, Version 2.0 the !License!

"# * you $ay not use this %i&e e'cept in co$p&iance (ith the License. * )ou $ay o*tain a copy o% the License at * * http+//(((.apache.org/&icenses/LIC,-.,/2.0 * * 0n&ess re1uired *y app&ica*&e &a( or agreed to in (riting, so%t(are * distri*uted under the License is distri*uted on an !A. I.! 2A.I., * WIT340T WA55A-TI,. 45 C4-6ITI4-. 47 A-) 8I-6, either e'press or i$p&ied. * .ee the License %or the speci%ic &anguage go9erning per$issions and * &i$itations under the License. * */ storedVars : ne( 4*;ect "# %unction .e&eniu$ *ro(ser*ot" < this.*ro(ser*ot : *ro(ser*ot# this.optionLocator7actory : ne( 4ptionLocator7actory "# this.page : %unction " < return *ro(ser*ot.getCurrent=age "# ># > .e&eniu$.create7or7ra$e : %unction %ra$e" < return ne( .e&eniu$ 2ro(ser2ot.create7or7ra$e %ra$e""# ># /* * 5eset the *ro(ser*ot (hen an error occurs.. */ .e&eniu$.prototype.reset : %unction " < storedVars : ne( 4*;ect "# this.*ro(ser*ot.se&ectWindo( !nu&&!"# ># /* * C&ick on the &ocated e&e$ent, and attach a ca&&*ack to noti%y * (hen the page is re&oaded. */ .e&eniu$.prototype.do?oda&6ia&ogTest : %unction returnVa&ue" < this.*ro(ser*ot.do?oda&6ia&ogTest returnVa&ue"# >#

/* * C&ick on the &ocated e&e$ent, and attach a ca&&*ack to noti%y * (hen the page is re&oaded. */ .e&eniu$.prototype.doC&ick : %unction &ocator" < 9ar e&e$ent : this.page ".%ind,&e$ent &ocator"# this.page ".c&ick,&e$ent e&e$ent"# ># /** * 49er(rite the te't in the &ocated te't e&e$ent. * T464 %ai& i% it can@t *e typed into. */ .e&eniu$.prototype.doType : %unction &ocator, ne(Te't" < 9ar e&e$ent : this.page ".%ind,&e$ent &ocator"# this.page ".rep&aceTe't e&e$ent, ne(Te't"# ># /** * .e&ect the option %ro$ the &ocated se&ect e&e$ent. */ .e&eniu$.prototype.do.e&ect : %unction &ocator, optionLocator" < 9ar e&e$ent : this.page ".%ind,&e$ent &ocator"# i% A !options! in e&e$ent"" < thro( ne( .e&eniu$,rror !.peci%ied e&e$ent is not a .e&ect has no options"!"# > 9ar &ocator : this.optionLocator7actory.%ro$Locator.tring optionLocator"# 9ar option : &ocator.%ind4ption e&e$ent"# this.page ".se&ect4ption e&e$ent, option"# ># /* * 4pen the *ro(ser to a ne( &ocation. */ .e&eniu$.prototype.do4pen : %unction ne(Location" < this.*ro(ser*ot.openLocation ne(Location"# return .,L,-I0?B=54C,..BWAIT# ># /* * .e&ect the na$ed (indo( to *e the acti9e (indo(. */ .e&eniu$.prototype.do.e&ectWindo( : %unction (indo(-a$e" < this.*ro(ser*ot.se&ectWindo( (indo(-a$e"#

># /* * Instruct .e&eniu$ to c&ick Cance& on the ne't con%ir$ dia&og it encounters */ .e&eniu$.prototype.doChooseCance&4n-e'tCon%ir$ation : %unction " < this.*ro(ser*ot.cance&-e'tCon%ir$ation "# ># /* * Instruct .e&eniu$ (hat to ans(ear on the ne't pro$pt dia&og it encounters */ .e&eniu$.prototype.doAns(er4n-e't=ro$pt : %unction ans(er" < this.*ro(ser*ot.set-e't=ro$pt5esu&t ans(er"# ># /* * .i$u&ate the *ro(ser *ack *utton */ .e&eniu$.prototype.doCo2ack : %unction " < this.page ".go2ack "# ># /* * C&ose the *ro(ser (indo( or ta* */ .e&eniu$.prototype.doC&ose : %unction " < this.page ".c&ose "# ># /* * ,'p&icit&y %ire an e9ent */ .e&eniu$.prototype.do7ire,9ent : %unction &ocator, e9ent" < 9ar e&e$ent : this.page ".%ind,&e$ent &ocator"# trigger,9ent e&e$ent, e9ent, %a&se"# ># /* * Cet an a&ert $essage, or %ai& i% there (ere no a&erts. */ .e&eniu$.prototype.getA&ert : %unction " < i% Athis.*ro(ser*ot.hasA&erts "" < Assert.%ai& !There (ere no a&erts!"#

> return this.*ro(ser*ot.get-e'tA&ert "# ># /* * Cet a con%ir$ation $essage, or %ai& i% there (ere no con%ir$ations. */ .e&eniu$.prototype.getCon%ir$ation : %unction " < i% Athis.*ro(ser*ot.hasCon%ir$ations "" < Assert.%ai& !There (ere no con%ir$ations!"# > return this.*ro(ser*ot.get-e'tCon%ir$ation "# ># /* * Cet a pro$pt $essage, or %ai& i% there (ere no pro$pts. */ .e&eniu$.prototype.get=ro$pt : %unction " < i% A this.*ro(ser*ot.has=ro$pts "" < Assert.%ai& !There (ere no pro$pts!"# > return this.*ro(ser*ot.get-e't=ro$pt "# ># /* * Cet the &ocation o% the current page. */ .e&eniu$.prototype.getA*so&uteLocation : %unction " < return this.page ".&ocation# ># /* * Veri%y the &ocation o% the current page ends (ith the e'pected &ocation. * I% a 1uerystring is pro9ided, this is checked as (e&&. */ .e&eniu$.prototype.assertLocation : %unction e'pectedLocation" < 9ar docLocation : this.page ".&ocation# 9ar search=os : e'pectedLocation.&astInde'4% @D@"# i% search=os :: /E" < Assert.$atches @*@ F e'pectedLocation, docLocation.pathna$e"# > e&se < 9ar e'pected=ath : e'pectedLocation.su*string 0, search=os"# Assert.$atches @*@ F e'pected=ath, docLocation.pathna$e"#

9ar e'pectedGuery.tring : e'pectedLocation.su*string search=os"# Assert.e1ua&s e'pectedGuery.tring, docLocation.search"# > ># /* * Cet the tit&e o% the current page. */ .e&eniu$.prototype.getTit&e : %unction " < return this.page ".tit&e "# ># /* * Cet the tri$$ed" 9a&ue o% a %or$ e&e$ent. * This is used to generate assertVa&ue, 9eri%yVa&ue, ... */ .e&eniu$.prototype.getVa&ue : %unction &ocator" < 9ar e&e$ent : this.page ".%ind,&e$ent &ocator" return getInputVa&ue e&e$ent".tri$ "# > /** * Cet the tri$$ed" te't o% a %or$ e&e$ent. * This is used to generate assertTe't, 9eri%yTe't, ... */ .e&eniu$.prototype.getTe't : %unction &ocator" < 9ar e&e$ent : this.page ".%ind,&e$ent &ocator"# return getTe't e&e$ent".tri$ "# ># /* * 5eturn the te't %or a sing&e ce&& (ithin an 3T?L ta*&e. * The ta*&e &ocator synta' is ta*&e.ro(.co&u$n. */ .e&eniu$.prototype.getTa*&e : %unction ta*&eLocator" < // This regu&ar e'pression $atches !ta*&e-a$e.ro(.co&u$n! // 7or e'a$p&e, !$yta*&e.H.4! pattern : / .*"I. IdF"I. IdF"/# i% Apattern.test ta*&eLocator"" < thro( ne( .e&eniu$,rror !In9a&id target %or$at. Correct %or$at is ta*&e-a$e.ro(-u$.co&u$n-u$!"# > pieces : ta*&eLocator.$atch pattern"#

ta*&e-a$e : piecesJEK# ro( : piecesJ2K# co& : piecesJHK# 9ar ta*&e : this.page ".%ind,&e$ent ta*&e-a$e"# i% ro( L ta*&e.ro(s.&ength" < Assert.%ai& !Cannot access ro( ! F ro( F ! / ta*&e has ! F ta*&e.ro(s.&ength F ! ro(s!"# > e&se i% co& L ta*&e.ro(sJro(K.ce&&s.&ength" < Assert.%ai& !Cannot access co&u$n ! F co& F ! / ta*&e ro( has ! F ta*&e.ro(sJro(K.ce&&s.&ength F ! co&u$ns!"# > e&se < actua&Content : getTe't ta*&e.ro(sJro(K.ce&&sJco&K"# return actua&Content.tri$ "# > ># /** * Veri%y that the se&ected option satis%ies the option &ocator. */ .e&eniu$.prototype.assert.e&ected : %unction target, optionLocator" < 9ar e&e$ent : this.page ".%ind,&e$ent target"# 9ar &ocator : this.optionLocator7actory.%ro$Locator.tring optionLocator"# &ocator.assert.e&ected e&e$ent"# ># .tring.prototype.parseC.V : %unction " < 9ar 9a&ues : this.rep&ace /II,/g, !In!".sp&it !,!"# // 5estore escaped co$$as %or 9ar i : 0# i M 9a&ues.&ength# iFF" < 9a&uesJiK : 9a&uesJiK.rep&ace /In/g, !,!".tri$ "# > return 9a&ues# ># /** * Veri%y the &a*e& o% a&& o% the options in the drop:do(n. */ .e&eniu$.prototype.assert.e&ect4ptions : %unction target, options" < 9ar e&e$ent : this.page ".%ind,&e$ent target"# 9ar e'pected4ptionLa*e&s : options.parseC.V "#

Assert.e1ua&s !Wrong nu$*er o% options!, e'pected4ptionLa*e&s.&ength, e&e$ent.options.&ength"# %or 9ar i : 0# i M e&e$ent.options.&ength# iFF" < Assert.$atches e'pected4ptionLa*e&sJiK, e&e$ent.optionsJiK.te't"# > ># /** * Cet the 9a&ue o% an e&e$ent attri*ute. The synta' %or returning an e&e$ent attri*ute * is Me&e$ent/&ocatorLNattri*ute/na$e. 0sed to generate assert, 9eri%y, assert-ot... */ .e&eniu$.prototype.getAttri*ute : %unction target" < return this.page ".%indAttri*ute target"# ># /* * Asserts that the speci%ied te't is present in the page content. */ .e&eniu$.prototype.assertTe't=resent : %unction e'pectedTe't" < 9ar a&&Te't : this.page ".*odyTe't "# i% a&&Te't :: !!" < Assert.%ai& !=age te't not %ound!"# > e&se i% a&&Te't.inde'4% e'pectedTe't" :: /E" < Assert.%ai& !@! F e'pectedTe't F !@ not %ound in page te't.!"# > ># /* * Asserts that the speci%ied te't is -4T present in the page content. */ .e&eniu$.prototype.assertTe't-ot=resent : %unction une'pectedTe't" < 9ar a&&Te't : this.page ".*odyTe't "# i% a&&Te't :: !!" < Assert.%ai& !=age te't not %ound!"# > e&se i% a&&Te't.inde'4% une'pectedTe't" A: /E" < Assert.%ai& !@! F une'pectedTe't F !@ (as %ound in page te't.!"# > ># /* * Asserts that the speci%ied e&e$ent can *e %ound.

*/ .e&eniu$.prototype.assert,&e$ent=resent : %unction &ocator" < try < this.page ".%ind,&e$ent &ocator"# > catch e" < Assert.%ai& !,&e$ent ! F &ocator F ! not %ound.!"# > ># /* * Asserts that the speci%ied e&e$ent cannot *e %ound. */ .e&eniu$.prototype.assert,&e$ent-ot=resent : %unction &ocator" < try < this.page ".%ind,&e$ent &ocator"# > catch e" < return# > Assert.%ai& !,&e$ent ! F &ocator F ! %ound.!"# ># /* * Asserts that the speci%ied e&e$ent is 9isi*&e */ .e&eniu$.prototype.assertVisi*&e : %unction &ocator" < 9ar e&e$ent# try < e&e$ent : this.page ".%ind,&e$ent &ocator"# > catch e" < Assert.%ai& !,&e$ent ! F &ocator F ! not present.!"# > i% A this.isVisi*&e e&e$ent"" < Assert.%ai& !,&e$ent ! F &ocator F ! not 9isi*&e.!"# > ># /* * Asserts that the speci%ied e&e$ent is 9isi*&e */ .e&eniu$.prototype.assert-otVisi*&e : %unction &ocator" < 9ar e&e$ent# try < e&e$ent : this.page ".%ind,&e$ent &ocator"# > catch e" < return# >

i% this.isVisi*&e e&e$ent"" < Assert.%ai& !,&e$ent ! F &ocator F ! is 9isi*&e.!"# > ># .e&eniu$.prototype.isVisi*&e : %unction e&e$ent" < 9ar 9isi*i&ity : this.get,%%ecti9e.ty&e=roperty e&e$ent, !9isi*i&ity!"# 9ar is6isp&ayed : this.is6isp&ayed e&e$ent"# return 9isi*i&ity A: !hidden! OO is6isp&ayed"# ># .e&eniu$.prototype.get,%%ecti9e.ty&e=roperty : %unction e&e$ent, property" < 9ar e%%ecti9e.ty&e : this.get,%%ecti9e.ty&e e&e$ent"# 9ar propertyVa&ue : e%%ecti9e.ty&eJpropertyK# i% propertyVa&ue :: @inherit@ OO e&e$ent.parent-ode.sty&e" < return this.get,%%ecti9e.ty&e=roperty e&e$ent.parent-ode, property"# > return propertyVa&ue# ># .e&eniu$.prototype.is6isp&ayed : %unction e&e$ent" < 9ar disp&ay : this.get,%%ecti9e.ty&e=roperty e&e$ent, !disp&ay!"# i% disp&ay :: !none!" return %a&se# i% e&e$ent.parent-ode.sty&e" < return this.is6isp&ayed e&e$ent.parent-ode"# > return true# ># .e&eniu$.prototype.get,%%ecti9e.ty&e : %unction e&e$ent" < i% e&e$ent.sty&e :: unde%ined" < return unde%ined# // not a sty&ed e&e$ent > 9ar (indo( : this.*ro(ser*ot.getContentWindo( "# i% (indo(.getCo$puted.ty&e" < // 64?/Le9e&/2/C.. return (indo(.getCo$puted.ty&e e&e$ent, nu&&"# > i% e&e$ent.current.ty&e" < // non/standard I, a&ternati9e return e&e$ent.current.ty&e# // T464+ this (on@t rea&&y (ork in a genera& sense, as // current.ty&e is not identica& to getCo$puted.ty&e " // ... *ut it@s good enough %or !9isi*i&ity! >

thro( ne( .e&eniu$,rror !cannot deter$ine e%%ecti9e sty&esheet in this *ro(ser!"# ># /** * Asserts that the speci%ied e&e$ent accepts user input 9isi*&e */ .e&eniu$.prototype.assert,dita*&e : %unction &ocator" < 9ar e&e$ent : this.page ".%ind,&e$ent &ocator"# i% e&e$ent.9a&ue :: unde%ined" < Assert.%ai& !,&e$ent ! F &ocator F ! is not an input.!"# > i% e&e$ent.disa*&ed" < Assert.%ai& !,&e$ent ! F &ocator F ! is disa*&ed.!"# > ># /** * Asserts that the speci%ied e&e$ent does not accept user input */ .e&eniu$.prototype.assert-ot,dita*&e : %unction &ocator" < 9ar e&e$ent : this.page ".%ind,&e$ent &ocator"# i% e&e$ent.9a&ue :: unde%ined" < return# // not an input > i% e&e$ent.disa*&ed :: %a&se" < Assert.%ai& !,&e$ent ! F &ocator F ! is edita*&e.!"# > ># /* * 5eturn a&& *uttons on the screen. */ .e&eniu$.prototype.getA&&2uttons : %unction " < return this.page ".getA&&2uttons "# ># /* * 5eturn a&& &inks on the screen. */ .e&eniu$.prototype.getA&&Links : %unction " < return this.page ".getA&&Links "# ># /* * 5eturn a&& %ie&ds on the screen. */

.e&eniu$.prototype.getA&&7ie&ds : %unction " < return this.page ".getA&&7ie&ds "# ># /* * .et the conte't %or the current Test */ .e&eniu$.prototype.doConte't : %unction conte't" < return this.page ".setConte't conte't"# ># /* * .tore the 9a&ue o% a %or$ input in a 9aria*&e */ .e&eniu$.prototype.do.toreVa&ue : %unction target, 9ar-a$e" < i% A9ar-a$e" < // 2ack(ard co$pati*i&ity $ode+ read the ,-TI5, te't o% the page // and stores it in a 9aria*&e (ith the na$e o% the target 9a&ue : this.page ".*odyTe't "# storedVarsJtargetK : 9a&ue# return# > 9ar e&e$ent : this.page ".%ind,&e$ent target"# storedVarsJ9ar-a$eK : getInputVa&ue e&e$ent"# ># /* * .tore the te't o% an e&e$ent in a 9aria*&e */ .e&eniu$.prototype.do.toreTe't : %unction target, 9ar-a$e" < 9ar e&e$ent : this.page ".%ind,&e$ent target"# storedVarsJ9ar-a$eK : getTe't e&e$ent"# ># /* * .tore the 9a&ue o% an e&e$ent attri*ute in a 9aria*&e */ .e&eniu$.prototype.do.toreAttri*ute : %unction target, 9ar-a$e" < storedVarsJ9ar-a$eK : this.page ".%indAttri*ute target"# ># /* * .tore the resu&t o% a &itera& 9a&ue */ .e&eniu$.prototype.do.tore : %unction 9a&ue, 9ar-a$e" < storedVarsJ9ar-a$eK : 9a&ue# >#

/* * Wait %or the target to ha9e the speci%ied 9a&ue *y po&&ing. * The po&&ing is done in TestLoop.kicko%%-e'tCo$$and,'ecution " */ .e&eniu$.prototype.doWait7orVa&ue : %unction target, 9a&ue" < 9ar e : this.page ".%ind,&e$ent target"# testLoop.(ait7orCondition : %unction " < return e.9a&ue :: 9a&ue"# ># ># /** * ,9a&uate a para$eter, per%or$ing ;a9ascript e9a&uation and 9aria*&e su*stitution. * I% the string $atches the pattern !;a9ascript< ... >!, e9a&uate the string *et(een the *races. */ .e&eniu$.prototype.preprocess=ara$eter : %unction 9a&ue" < 9ar $atch : 9a&ue.$atch /P;a9ascriptI< .F"I>Q/"# i% $atch OO $atchJEK" < return e9a& $atchJEK".to.tring "# > return this.rep&aceVaria*&es 9a&ue"# ># /* * .earch through str and rep&ace a&& 9aria*&e re%erences Q<9ar-a$e> (ith their * 9a&ue in storedVars. */ .e&eniu$.prototype.rep&aceVaria*&es : %unction str" < 9ar string5esu&t : str# // 7ind a&& o% the $atching 9aria*&e re%erences 9ar $atch : string5esu&t.$atch /IQI<I(FI>/g"# i% A$atch" < return string5esu&t# > // 7or each $atch, &ookup the 9aria*&e 9a&ue, and rep&ace i% %ound %or 9ar i : 0# $atch OO i M $atch.&ength# iFF" < 9ar 9aria*&e : $atchJiK# // The rep&ace$ent 9aria*&e, (ith Q<> 9ar na$e : 9aria*&e.su*string 2, 9aria*&e.&ength / E"# // The rep&ace$ent 9aria*&e (ithout Q<> 9ar rep&ace$ent : storedVarsJna$eK#

i% rep&ace$ent A: unde%ined" < string5esu&t : string5esu&t.rep&ace 9aria*&e, rep&ace$ent"# > > return string5esu&t# ># /** * 7actory %or creating !4ption Locators!. * An 4ptionLocator is an o*;ect %or dea&ing (ith .e&ect options e.g. %or * %inding a speci%ied option, or asserting that the se&ected option o% * .e&ect e&e$ent $atches so$e condition. * The type o% &ocator returned *y the %actory depends on the &ocator string+ * &a*e&:Me'pL 4ptionLocator2yLa*e&" * 9a&ue:Me'pL 4ptionLocator2yVa&ue" * inde':Me'pL 4ptionLocator2yInde'" * id:Me'pL 4ptionLocator2yId" * Me'pL de%au&t is 4ptionLocator2yLa*e&". */ %unction 4ptionLocator7actory " < > 4ptionLocator7actory.prototype.%ro$Locator.tring : %unction &ocator.tring" < 9ar &ocatorType : @&a*e&@# 9ar &ocatorVa&ue : &ocator.tring# // I% there is a &ocator pre%i', use the speci%ied strategy 9ar resu&t : &ocator.tring.$atch /P Ja/RA/SKF": .*"/"# i% resu&t" < &ocatorType : resu&tJEK# &ocatorVa&ue : resu&tJ2K# > i% this.optionLocators :: unde%ined" < this.register4ptionLocators "# > i% this.optionLocatorsJ&ocatorTypeK" < return ne( this.optionLocatorsJ&ocatorTypeK &ocatorVa&ue"# > thro( ne( .e&eniu$,rror !0nko(n option &ocator type+ ! F &ocatorType"# ># /** * To a&&o( %or easy e'tension, a&& o% the option &ocators are %ound *y

* searching %or a&& $ethods o% 4ptionLocator7actory.prototype that start * (ith !4ptionLocator2y!. * T464+ Consider using the ter$ !4ption .peci%ier! instead o% !4ption Locator!. */ 4ptionLocator7actory.prototype.register4ptionLocators : %unction " < this.optionLocators:<># %or 9ar %unction-a$e in this" < 9ar resu&t : /4ptionLocator2y JA/SK.F"Q/.e'ec %unction-a$e"# i% resu&t A: nu&&" < 9ar &ocator-a$e : resu&tJEK.&c%irst "# this.optionLocatorsJ&ocator-a$eK : thisJ%unction-a$eK# > > ># /** * 4ptionLocator %or options identi%ied *y their &a*e&s. */ 4ptionLocator7actory.prototype.4ptionLocator2yLa*e& : %unction &a*e&" < this.&a*e& : &a*e&# this.&a*e&?atcher : ne( =attern?atcher this.&a*e&"# this.%ind4ption : %unction e&e$ent" < %or 9ar i : 0# i M e&e$ent.options.&ength# iFF" < i% this.&a*e&?atcher.$atches e&e$ent.optionsJiK.te't"" < return e&e$ent.optionsJiK# > > thro( ne( .e&eniu$,rror !4ption (ith &a*e& @! F this.&a*e& F !@ not %ound!"# ># this.assert.e&ected : %unction e&e$ent" < 9ar se&ectedLa*e& : e&e$ent.optionsJe&e$ent.se&ectedInde'K.te't# Assert.$atches this.&a*e&, se&ectedLa*e&"# ># ># /** * 4ptionLocator %or options identi%ied *y their 9a&ues. */ 4ptionLocator7actory.prototype.4ptionLocator2yVa&ue : %unction 9a&ue" < this.9a&ue : 9a&ue# this.9a&ue?atcher : ne( =attern?atcher this.9a&ue"#

this.%ind4ption : %unction e&e$ent" < %or 9ar i : 0# i M e&e$ent.options.&ength# iFF" < i% this.9a&ue?atcher.$atches e&e$ent.optionsJiK.9a&ue"" < return e&e$ent.optionsJiK# > > thro( ne( .e&eniu$,rror !4ption (ith 9a&ue @! F this.9a&ue F !@ not %ound!"# ># this.assert.e&ected : %unction e&e$ent" < 9ar se&ectedVa&ue : e&e$ent.optionsJe&e$ent.se&ectedInde'K.9a&ue# Assert.$atches this.9a&ue, se&ectedVa&ue"# ># ># /** * 4ptionLocator %or options identi%ied *y their inde'. */ 4ptionLocator7actory.prototype.4ptionLocator2yInde' : %unction inde'" < this.inde' : -u$*er inde'"# i% is-a- this.inde'" TT this.inde' M 0" < thro( ne( .e&eniu$,rror !I&&ega& Inde'+ ! F inde'"# > this.%ind4ption : %unction e&e$ent" < i% e&e$ent.options.&ength M: this.inde'" < thro( ne( .e&eniu$,rror !Inde' out o% range. 4n&y ! F e&e$ent.options.&ength F ! options a9ai&a*&e!"# > return e&e$ent.optionsJthis.inde'K# ># this.assert.e&ected : %unction e&e$ent" < Assert.e1ua&s this.inde', e&e$ent.se&ectedInde'"# ># ># /** * 4ptionLocator %or options identi%ied *y their id. */ 4ptionLocator7actory.prototype.4ptionLocator2yId : %unction id" < this.id : id# this.id?atcher : ne( =attern?atcher this.id"# this.%ind4ption : %unction e&e$ent" <

%or 9ar i : 0# i M e&e$ent.options.&ength# iFF" < i% this.id?atcher.$atches e&e$ent.optionsJiK.id"" < return e&e$ent.optionsJiK# > > thro( ne( .e&eniu$,rror !4ption (ith id @! F this.id F !@ not %ound!"# ># this.assert.e&ected : %unction e&e$ent" < 9ar se&ectedId : e&e$ent.optionsJe&e$ent.se&ectedInde'K.id# Assert.$atches this.id, se&ectedId"# ># >#

You might also like