Commit b98d9476b548bb1131102cbd5b3d4ad0ebfb6a5e

Authored by tomek
1 parent dec22821

Implemented methods to obtain data from dataTable and schedule.

@@ -6,7 +6,10 @@ import com.gargoylesoftware.htmlunit.html.DomNodeList; @@ -6,7 +6,10 @@ import com.gargoylesoftware.htmlunit.html.DomNodeList;
6 import com.gargoylesoftware.htmlunit.html.HtmlElement; 6 import com.gargoylesoftware.htmlunit.html.HtmlElement;
7 import com.gargoylesoftware.htmlunit.html.HtmlInput; 7 import com.gargoylesoftware.htmlunit.html.HtmlInput;
8 import com.gargoylesoftware.htmlunit.html.HtmlPage; 8 import com.gargoylesoftware.htmlunit.html.HtmlPage;
  9 +import com.gargoylesoftware.htmlunit.html.HtmlSpan;
  10 +import com.gargoylesoftware.htmlunit.html.HtmlTable;
9 import com.gargoylesoftware.htmlunit.html.HtmlTableCell; 11 import com.gargoylesoftware.htmlunit.html.HtmlTableCell;
  12 +import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
10 13
11 import java.io.IOException; 14 import java.io.IOException;
12 import java.util.ArrayList; 15 import java.util.ArrayList;
@@ -81,10 +84,12 @@ public class WebClientUtils { @@ -81,10 +84,12 @@ public class WebClientUtils {
81 @SuppressWarnings("unchecked") 84 @SuppressWarnings("unchecked")
82 final DomNodeList<HtmlElement> suggestionRows = suggestElement.getElementsByTagName("tr"); 85 final DomNodeList<HtmlElement> suggestionRows = suggestElement.getElementsByTagName("tr");
83 for (HtmlElement row : suggestionRows) { 86 for (HtmlElement row : suggestionRows) {
84 - @SuppressWarnings("unchecked")  
85 - final DomNodeList<HtmlElement> cells = row.getElementsByTagName("td");  
86 - final HtmlTableCell cell = (HtmlTableCell) cells.get(column + 1);  
87 - suggestions.put(cell.asText(), cell); 87 + if (!row.getId().endsWith("NothingLabel")) {
  88 + @SuppressWarnings("unchecked")
  89 + final DomNodeList<HtmlElement> cells = row.getElementsByTagName("td");
  90 + final HtmlTableCell cell = (HtmlTableCell) cells.get(column + 1);
  91 + suggestions.put(cell.asText(), cell);
  92 + }
88 } 93 }
89 return suggestions; 94 return suggestions;
90 } 95 }
@@ -146,4 +151,19 @@ public class WebClientUtils { @@ -146,4 +151,19 @@ public class WebClientUtils {
146 ((HtmlInput) page.getElementById(colorPicker.getId() + "-colorPicker-rgb-b")).setValueAttribute(Integer.toString(blue)); 151 ((HtmlInput) page.getElementById(colorPicker.getId() + "-colorPicker-rgb-b")).setValueAttribute(Integer.toString(blue));
147 page.getElementById(colorPicker.getId() + "-colorPicker-popup").getHtmlElementsByTagName("button").get(0).click(); 152 page.getElementById(colorPicker.getId() + "-colorPicker-popup").getHtmlElementsByTagName("button").get(0).click();
148 } 153 }
  154 +
  155 + @SuppressWarnings("unchecked")
  156 + public static List<HtmlTableRow> getTableRows(HtmlTable table) {
  157 + return (List<HtmlTableRow>) table.getByXPath(".//*[contains(@class,'rich-table-row')]");
  158 + }
  159 +
  160 + @SuppressWarnings("unchecked")
  161 + public static List<String> getScheduleEventTitles(HtmlElement schedule) {
  162 + final List<HtmlSpan> titleElements = (List<HtmlSpan>) schedule.getByXPath(".//*[@class='fc-event-title']");
  163 + List<String> titles = new ArrayList<String>(titleElements.size());
  164 + for (HtmlSpan o : titleElements) {
  165 + titles.add(o.asText());
  166 + }
  167 + return titles;
  168 + }
149 } 169 }
Please register or login to post a comment