HtmlUnit 使用 HtmlSearchInput 进行搜索

问题描述

我正在尝试使用搜索类型的输入进行搜索。但似乎不起作用。 当我在搜索输入中键入搜索字符串并按回车键时,它在网站中工作。但无法使用我的代码完成它。我该如何解决

HtmlSearchInput searchBox = (HtmlSearchInput) page.getByXPath("//input[@class='searchinput1']").get(1);
searchBox.setValueAttribute("Toys");
HtmlPage page2 = (HtmlPage) searchBox.type('\n');

Thread.sleep(2000);
WEB_CLIENT.getoptions().setJavaScriptEnabled(true);
WEB_CLIENT.waitForBackgroundJavaScript(350000);

HtmlPage page3= (HtmlPage) WEB_CLIENT.getCurrentwindow().getEnclosedPage();

System.out.println(Jsoup.parse(page.asText()).html());
System.out.println(Jsoup.parse(page2.asText()).html());
System.out.println(Jsoup.parse(page3.asText()).html());

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)