our wiki is here: http://cwiki.apache.org/WICKET register yourself an account and you should be good to go.
-igor On Tue, Feb 16, 2010 at 9:43 PM, Douglas Ferguson <[email protected]> wrote: > Igor, > > I have a decent solution and could put together a wiki page, just need to > know where/how.. > > here's what I've got. > > Click and Wait for wicket: > > protected void clickAndWait(String wicketPath, long timeOut){ > String callbackScript = > "if(!window.outstandingWicketCalls){" + > " window.outstandingWicketCalls = 0;" + > " var oldWicketGlobalPreCallHandler = > window.wicketGlobalPreCallHandler;" + > " var oldWicketGlobalPostCallHandler = > window.wicketGlobalPostCallHandler;" + > " window.wicketGlobalPreCallHandler = > function() {" + > " window.outstandingWicketCalls++; "+ > " oldWicketGlobalPreCallHandler();" + > " };" + > " window.wicketGlobalPostCallHandler = function() > {" + > " oldWicketGlobalPostCallHandler();" + > " window.outstandingWicketCalls--; "+ > " };" + > "}" + > "window.write(window.outstandingWicketCalls);"; > > selenium.runScript(callbackScript); > click(wicketPath); > > selenium.waitForCondition("selenium.browserbot.getCurrentWindow();window.outstandingWicketCalls===0", > Duration.seconds(8).getMilliseconds() +""); > } > > > Deal with unstable wicket paths > > protected String getDOMLocator(String xpathTagName, String wicketPath, > int index){ > > String regex = "_(\\d+|#)(_|$)"; > Pattern repeaterWicketPathPatter = Pattern.compile(regex); > Matcher matcher = repeaterWicketPathPatter.matcher(wicketPath); > > while(matcher.find()){ > try{ > if(index == -1){ > index = > Integer.parseInt(matcher.group(1)); > } > > String xpathRegex = "_[0-9]+"; > if("_".equals(matcher.group(2))){ > xpathRegex = xpathRegex + "_"; > } > wicketPath = > wicketPath.replace(matcher.group(), xpathRegex); > }catch(NumberFormatException nfe){ > fail("index is required for getDOMLocator, > please pass it to the method or as the first numeric value in the wicketpath > provide i.e. foo_bar_134_child_#_child2_#"); > } > } > > StringWriter domLocator = new StringWriter(); > domLocator.append("dom="); > > if(index > 0){ > domLocator.append("window.findElementByWicketPath('"); > domLocator.append(wicketPath); > domLocator.append("', "); > domLocator.append(String.valueOf(index-1)); > domLocator.append(");"); > }else { > domLocator.append("window.$('[wicketpath=\\'"); > domLocator.append(wicketPath); > domLocator.append("\\']').get(0);"); > } > return domLocator.toString(); > } > > > Douglas Ferguson > > mobile: 512.293.7279 > office/fax: 512.462.0408 > skype: stillrecording > aim: DaAmericanRuse > > - > > http://www.linkedin.com/in/douglasferguson > http://www.myspace.com/douglasferguson > http://www.douglasferguson.us/ > http://www.distilleryrecords.com/ > http://www.stillrecording.com/ > > Join my mailing list: [email protected] > ________________________________________ > From: Igor Vaynberg [[email protected]] > Sent: Tuesday, February 16, 2010 11:11 AM > To: [email protected] > Subject: Re: Selenium Testing - Ajax Loads > > how would you do that exactly? > > -igor > > On Tue, Feb 16, 2010 at 7:26 AM, Douglas Ferguson > <[email protected]> wrote: >> >>> the path in repeaters is never stable, it depends on a lot of factors >>> and is hard to predict. i think what may be a good way to deal with it >>> is to use an IComponentInstantiationListener to add a behavior to Item >>> subclasses to output their index in some attribute. install this >>> listener only during test time or simply make it output nothing if not >>> during the test. >>> >> >> Interesting.... I'll look into it.. >> Is there really any reason why not to just always have the listener there. >> Seems like there would be little overhead in doing this... >> >> But I am curious, if this can be done then why couldn't the wicket page also >> be made stable using the same technique? >> >>>>>> 2) I have issues with timing which is typical, and most people call >>>>>> "waitForPageToLoad" which works fine for normal http requests, but if It >>>>>> is an ajax request I'm waiting for, then I have to implement a >>>>>> waitForContition. Is there a wicket convention I could use here? i.e. >>>>>> how can I know that a wicket ajax call has completed? >>>>> >>>>> there are global ajax callbacks that are invoked when an ajax request >>>>> completes. you can search this list for what they are. i imagine you >>>>> can write a bit of javascript to hook into those and implement >>>>> waitForCondition. >>>> >>>> I'm actually using the window.wicketGlobalPreCallHandler and >>>> window.wicketGlobalPostCallHandler in my code already. >>>> Do you think it would be safe to use those? I.E. preHander sets a boolean >>>> "isWaitingOnAjax" and postHander unsets it? >>>> >>>> Then I can do a waitForConition(!isWaitingOnAjax) >>> >>> yeah, that sounds like a good starting point. >>> >>> -igor >>> >>>> >>>>> >>>>> when you get all this working maybe you can create a wiki page about >>>>> it to help users who will have the same questions in the future. >>>> >>>> Sounds good... >>>> >>>>> >>>>> -igor >>>>> >>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> D/ >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: [email protected] >>>>>> For additional commands, e-mail: [email protected] >>>>>> >>>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [email protected] >>>>> For additional commands, e-mail: [email protected] >>>>> >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
