diff --git a/src/main/java/pl/labno/bernard/htmlunified/WebClientUtils.java b/src/main/java/pl/labno/bernard/htmlunified/WebClientUtils.java index 1940566..f27e747 100644 --- a/src/main/java/pl/labno/bernard/htmlunified/WebClientUtils.java +++ b/src/main/java/pl/labno/bernard/htmlunified/WebClientUtils.java @@ -9,6 +9,7 @@ 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.HtmlTableDataCell; import com.gargoylesoftware.htmlunit.html.HtmlTableRow; import java.io.IOException; @@ -158,12 +159,23 @@ public class WebClientUtils { } @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; + public static List getScheduleEventTitles(HtmlElement schedule) { + return (List) schedule.getByXPath(".//*[@class='fc-event-title']"); + } + + public static void switchScheduleToNextMonth(HtmlElement schedule) throws IOException { + ((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 + */ + public static HtmlTableDataCell getScheduleDayCell(HtmlElement schedule, int dayOfMonth) { + return (HtmlTableDataCell) schedule.getByXPath(".//td[contains(@class,'fc-day') and not(contains(@class,'fc-other-month'))]").get(dayOfMonth - 1); } }