Commit c4130b76b52fa72985f0e20f53b4e9ae38664d16
1 parent
f76f0d3e
Implemented setColorPicker method in WebClientUtils
Showing
1 changed file
with
18 additions
and
0 deletions
... | ... | @@ -4,9 +4,11 @@ import com.gargoylesoftware.htmlunit.WebClient; |
4 | 4 | import com.gargoylesoftware.htmlunit.html.DomNode; |
5 | 5 | import com.gargoylesoftware.htmlunit.html.DomNodeList; |
6 | 6 | import com.gargoylesoftware.htmlunit.html.HtmlElement; |
7 | +import com.gargoylesoftware.htmlunit.html.HtmlInput; | |
7 | 8 | import com.gargoylesoftware.htmlunit.html.HtmlPage; |
8 | 9 | import com.gargoylesoftware.htmlunit.html.HtmlTableCell; |
9 | 10 | |
11 | +import java.io.IOException; | |
10 | 12 | import java.util.ArrayList; |
11 | 13 | import java.util.HashMap; |
12 | 14 | import java.util.List; |
... | ... | @@ -128,4 +130,20 @@ public class WebClientUtils { |
128 | 130 | } |
129 | 131 | } |
130 | 132 | } |
133 | + | |
134 | + public static void setColorPickerValue(WebClient webClient, HtmlElement colorPicker, String hex) throws IOException { | |
135 | + HtmlPage page = (HtmlPage) webClient.getCurrentWindow().getEnclosedPage(); | |
136 | + colorPicker.click(); | |
137 | + ((HtmlInput) page.getElementById(colorPicker.getId() + "-colorPicker-hex")).setValueAttribute(hex); | |
138 | + page.getElementById(colorPicker.getId() + "-colorPicker-popup").getHtmlElementsByTagName("button").get(0).click(); | |
139 | + } | |
140 | + | |
141 | + public static void setColorPickerValue(WebClient webClient, HtmlElement colorPicker, int red, int green, int blue) throws IOException { | |
142 | + HtmlPage page = (HtmlPage) webClient.getCurrentWindow().getEnclosedPage(); | |
143 | + colorPicker.click(); | |
144 | + ((HtmlInput) page.getElementById(colorPicker.getId() + "-colorPicker-rgb-r")).setValueAttribute(Integer.toString(red)); | |
145 | + ((HtmlInput) page.getElementById(colorPicker.getId() + "-colorPicker-rgb-g")).setValueAttribute(Integer.toString(green)); | |
146 | + ((HtmlInput) page.getElementById(colorPicker.getId() + "-colorPicker-rgb-b")).setValueAttribute(Integer.toString(blue)); | |
147 | + page.getElementById(colorPicker.getId() + "-colorPicker-popup").getHtmlElementsByTagName("button").get(0).click(); | |
148 | + } | |
131 | 149 | } | ... | ... |
Please
register
or
login
to post a comment