final WebClient webClient = new WebClient();
HtmlPage page = null;
try {
page = webClient.getPage("http://google.com");
} catch (IOException e) {
// e.printStackTrace();
System.out.println("Exaption");
}
HtmlInput searchBox = page.getElementByName("q");
searchBox.setValueAttribute("Selenium");
System.out.println(searchBox);
DomElement element = page.getFirstByXPath("//span[@text='Selenium']");
if (element != null) {
System.out.println(element.asText());
} else {
System.out.println("null");
}
Html:
<img class="icon_suggest icon_tag-img" src="https://habrastorage.org/webt/5a/f3/20/5af32059891a0495611397.png"><span>Selenium</span>
Я хочу нажать «icon_suggest icon_tag-img» на странице https://qna.habr.com/ (введите Selenium в поиске)
Селен