diff --git a/src/main/java/pl/labno/bernard/htmlunified/WebClientUtils.java b/src/main/java/pl/labno/bernard/htmlunified/WebClientUtils.java index 000bcbc..1940566 100644 --- a/src/main/java/pl/labno/bernard/htmlunified/WebClientUtils.java +++ b/src/main/java/pl/labno/bernard/htmlunified/WebClientUtils.java @@ -6,7 +6,10 @@ import com.gargoylesoftware.htmlunit.html.DomNodeList; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlInput; import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.gargoylesoftware.htmlunit.html.HtmlSpan; +import com.gargoylesoftware.htmlunit.html.HtmlTable; import com.gargoylesoftware.htmlunit.html.HtmlTableCell; +import com.gargoylesoftware.htmlunit.html.HtmlTableRow; import java.io.IOException; import java.util.ArrayList; @@ -81,10 +84,12 @@ public class WebClientUtils { @SuppressWarnings("unchecked") final DomNodeList suggestionRows = suggestElement.getElementsByTagName("tr"); for (HtmlElement row : suggestionRows) { - @SuppressWarnings("unchecked") - final DomNodeList cells = row.getElementsByTagName("td"); - final HtmlTableCell cell = (HtmlTableCell) cells.get(column + 1); - suggestions.put(cell.asText(), cell); + if (!row.getId().endsWith("NothingLabel")) { + @SuppressWarnings("unchecked") + final DomNodeList cells = row.getElementsByTagName("td"); + final HtmlTableCell cell = (HtmlTableCell) cells.get(column + 1); + suggestions.put(cell.asText(), cell); + } } return suggestions; } @@ -146,4 +151,19 @@ public class WebClientUtils { ((HtmlInput) page.getElementById(colorPicker.getId() + "-colorPicker-rgb-b")).setValueAttribute(Integer.toString(blue)); page.getElementById(colorPicker.getId() + "-colorPicker-popup").getHtmlElementsByTagName("button").get(0).click(); } + + @SuppressWarnings("unchecked") + public static List getTableRows(HtmlTable table) { + return (List) table.getByXPath(".//*[contains(@class,'rich-table-row')]"); + } + + @SuppressWarnings("unchecked") + public static List getScheduleEventTitles(HtmlElement schedule) { + final List titleElements = (List) schedule.getByXPath(".//*[@class='fc-event-title']"); + List titles = new ArrayList(titleElements.size()); + for (HtmlSpan o : titleElements) { + titles.add(o.asText()); + } + return titles; + } }