thrownewRuntimeException("Number of JavaScript jobs doesn't drop to initial level for "+timeout+" seconds. It's memory leak in your JavaScript rather then request taking so long!");
returnjobs;}/** * Returns list of suggestions from rich:suggestionBox * * @param suggestion suggestionBox element * @param column column of suggestionBox to extract text from * @return list of suggestions */publicstaticMap<String,HtmlTableCell>getSuggestions(HtmlElementsuggestion,intcolumn){finalMap<String,HtmlTableCell>suggestions=newHashMap<String,HtmlTableCell>();finalHtmlElementsuggestElement=suggestion.getElementById(suggestion.getId()+":suggest");@SuppressWarnings("unchecked")finalDomNodeList<HtmlElement>suggestionRows=suggestElement.getElementsByTagName("tr");for(HtmlElementrow:suggestionRows){
publicstaticvoidexecuteAjaxReRenderedScripts(HtmlPagepage){finalDomNodeList<HtmlElement>scripts=page.getElementsByTagName("script");/** * We cannot iterate over html DomNodeList cause it depends on sibling relationship which we will modify. */finalList<HtmlElement>scriptsList=newArrayList<HtmlElement>();for(HtmlElementelement:scripts){scriptsList.add(element);}for(HtmlElementelement:scriptsList){if(element.getChildNodes().size()>1){element.removeChild(element.getFirstChild());finalDomNodesibling=element.getNextSibling();finalDomNodeparentNode=element.getParentNode();/** * Script will be executed upon inserting into DOM tree, so we removed and add it again. */if(sibling!=null){parentNode.removeChild(element);sibling.insertBefore(element);}else{parentNode.removeChild(element);parentNode.appendChild(element);}}}}
publicstaticList<HtmlSpan>getScheduleEventTitles(HtmlElementschedule){return(List<HtmlSpan>)schedule.getByXPath(".//*[@class='fc-event-title']");}publicstaticvoidswitchScheduleToNextMonth(HtmlElementschedule)throwsIOException{((HtmlElement)schedule.getByXPath(".//*[contains(@class,'fc-button-next')]").get(0)).click();}/** * IMPORTANT: Because of bugs in htmlunit and jsfunit which make schedule component render improperly this method should be used only to retrieve * cell elements from the first row of schedule grid. Any operations on cell elements from other rows are likely to cause error. * * @param schedule schedule element * @param dayOfMonth number of day of month representing cell you wish to retrieve * @return list of schedule cells */publicstaticHtmlTableDataCellgetScheduleDayCell(HtmlElementschedule,intdayOfMonth){return(HtmlTableDataCell)schedule.getByXPath(".//td[contains(@class,'fc-day') and not(contains(@class,'fc-other-month'))]").get(dayOfMonth-1);