请在这里找到我的代码段,我使用在Linux rhel
箱:司机的HtmlUnit给我com.gargoylesoftware.htmlunit.html.HtmlPage不能转换到com.gargoylesoftware.htmlunit.InteractivePage错误
WebDriver driver = new HtmlUnitDriver();
driver.get("https://www.amazon.com/ap/register?_encoding=UTF8&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fyourstore%2Fhome%3Fie%3DUTF8%26ref_%3Dnav_newcust");
driver.findElement(By.id("ap_customer_name")).sendKeys("krish"); // line 24
我收到以下错误:
Exception in thread "main" java.lang.ClassCastException: com.gargoylesoftware.htmlunit.html.HtmlPage cannot be cast to com.gargoylesoftware.htmlunit.InteractivePage
at org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitTargetLocator.activeElement(HtmlUnitDriver.java:1332)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.switchFocusToThisIfNeeded(HtmlUnitWebElement.java:292)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.sendKeys(HtmlUnitWebElement.java:330)
at com.amazon.digitalmusic.UnitBrowser.main(UnitBrowser.java:24)
HTMLunit-2.17和硒jar文件在我的项目路径中。
我尝试了谷歌搜索,但无法解决它。对此有所帮助,我哪里出错了。
在此先感谢