請在這裏找到我的代碼段,我使用在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文件在我的項目路徑中。
我嘗試了谷歌搜索,但無法解決它。對此有所幫助,我哪裏出錯了。
在此先感謝