question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot call method "getElementsByClassName" of undefined

See original GitHub issue

EcmaError: lineNumber=[5] column=[0] lineSource=[ const prevButton = carousel.parentElement.getElementsByClassName("carousel-previous-button")[0];] name=[TypeError] sourceName=[https://www.fdic.gov/assets/javascript/carousels.js] message=[TypeError: Cannot call method "getElementsByClassName" of undefined (https://www.fdic.gov/assets/javascript/carousels.js#5)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method "getElementsByClassName" of undefined (https://www.fdic.gov/assets/javascript/carousels.js#5) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:891) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:619) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:537) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.callSecured(HtmlUnitContextFactory.java:354)

Getting the above JavaScript exception when trying to scrape https://www.fdic.gov/news/press-releases/2020/

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rbricommented, Aug 3, 2020

Does your change just ignores the exception?

You think i need a whole week only to suppress the exception?

The page includes several js parts - usually huge js scripts. It will not be that easy to figure out why some js parts are working different from real browsers. If you like to get this fixed you can help to nail down the problem to the problematic function. You can have a look at https://htmlunit.sourceforge.io/submittingJSBugs.html for some hints how to do it.

1reaction
rbricommented, Jul 29, 2020

Will try to get this done during this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Chrome - Uncaught TypeError: Cannot call method ...
You're not calling it on document . You're calling it on document.getElementById('wan1ip'). Make sure the element exists.
Read more >
Document.getElementsByClassName() - Web APIs | MDN
The getElementsByClassName method of Document interface returns an array-like object of all child elements which have all of the given class ...
Read more >
HTML DOM Element getElementsByClassName() - W3Schools
The getElementsByClassName() method returns a collection of child elements with a given class name. The getElementsByClassName() method returns a NodeList ...
Read more >
TypeError: Cannot read Property 'add' of Undefined in JS
The cannot read property 'add' of undefined error occurs when calling the add() method on an undefined value. To solve the error, ...
Read more >
How To Fix Cannot Read Property 'style' of Null in JavaScript
Make sure the element you are trying to access has an id. In your document.getElementById() function call, make sure you type that id...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found