如何在Selenium的HtmlUnitDriver中避免JavaScript错误?

时间:2015-11-23 11:30:18

标签: javascript selenium htmlunit selenium-chromedriver htmlunit-driver

我是Selenium的新手,我正在尝试连接到某个网站。

String url = [url][1]

    WebDriver driver = new HtmlUnitDriver(true);

    driver.get(url);

我在执行此行时遇到JavaScript错误。

我搜索了几个问题并尝试了

    driver.setJavascriptEnabled(true);

仍然在drive.get(url)行产生同样的问题。

我无法在这里找到实际问题。

谁能告诉我这背后的主要问题是什么? 这个页面需要花费更多的时间来加载吗? 还是其他任何原因?

我还会粘贴问题的输出文本。在这下面

Nov 23, 2015 5:03:15 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify

WARNING: Obsolete content type encountered: 'application/x-javascript'.

Nov 23, 2015 5:03:17 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify

WARNING: Obsolete content type encountered: 'application/x-javascript'.

Nov 23, 2015 5:03:21 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify

WARNING: Obsolete content type encountered: 'application/x-javascript'.

Exception in thread "main" org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: 

TypeError: TypeError: redeclaration of const constructor.

Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'

System info: host: 'User-PC', ip: '192.168.1.66', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.
version: '1.8.0_40'

Driver info: driver.version: HtmlUnitDriver
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:554)

0 个答案:

没有答案