2

I'm new to Selenium and I'm trying to connect to a site.

String url = [url][1]

    WebDriver driver = new HtmlUnitDriver(true);

    driver.get(url);

I'm facing JavaScript errors while executing this line.

I searched few questions and also tried

    driver.setJavascriptEnabled(true);

Still it is generating same problem in drive.get(url) line.

I'm unable to find the actual problem here.

Can anyone tell me what is the main problem behind this? Is it the page that takes little more time to load? Or any other reason?

I've also paste the output text of the problem. here below

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)
Rajendra Maharjan
  • 215
  • 1
  • 4
  • 13
  • Please provide the URL, so others can check. http://stackoverflow.com/help/mcve – Ahmed Ashour Nov 23 '15 at 12:09
  • @AhmedAshour link url =https://www.kcmo.org/Ads/faces/AdSearch.jspx?_afrWindowMode=0&_afrLoop=1001263381394588&_adf.ctrl-state=kzoykemys_14 – Rajendra Maharjan Nov 24 '15 at 06:28
  • You can't avoid javascript errors, you could turn it off in case you don't need javascript on the page to work properly or you can set the throwexceptiononscripterror (not sure about the correct name, has been a while I used it last) to false to just ignore all javascript errors. This might just lead to the application not working properly. Alternatively take a look at PhantomJS which has better javascript support – rac2030 May 14 '16 at 11:05
  • Possible duplicate of [HtmlUnit ignore JavaScript errors?](http://stackoverflow.com/questions/21294707/htmlunit-ignore-javascript-errors) – stiemannkj1 Feb 24 '17 at 02:45

0 Answers0