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.

IllegalStateException: No script object associated with the Page

See original GitHub issue

I guess it happens when

  1. A page with frames is being parsed, and
  2. One of frames changes URL
  3. Then HtmlUnit tries to generate an “unload” event for the page which is not fully parsed yet (and therefore has getScriptableObject() == null).

I have a reproducible case in Selenide framework: https://github.com/selenide/selenide/blob/master/src/test/java/integration/FrameWaitTest.java

Try to run it several times: it fails time-to-time with the following error:

org.openqa.selenium.WebDriverException: java.lang.IllegalStateException: No script object associated with the Page. class: 'com.gargoylesoftware.htmlunit.html.HtmlPage' url: 'http://127.0.0.1:14702/page_with_frames.html' content: <!DOCTYPE html>
<html lang="en">
<head>
  <title>Test::frames</title>
  <meta charset="UTF-8">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<frameset rows="80,*" cols="*">
  <frame src="hello_world.txt" name="topFrame" id="top-frame" scrolling="no" noresize>
  <frameset cols="300,*">
    <frame src="page_with_dynamic_select.html" name="leftFrame" scrolling="no" noresize>
    <frame src="page_with_jquery.html" name="mainFrame">
    <frame src="page_with_parent_frame.html" name="parentFrame">
  </frameset>
</frameset>
</html>

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'Andreis-MacBook-Pro.local', ip: 'fe80:0:0:0:4a3:96eb:183c:fbf%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_144'
Driver info: driver.version: HtmlUnitDriver
selenide.url: http://127.0.0.1:14702/page_with_frames_with_delays.html?browser=htmlunit&timeout=4000
selenide.baseUrl: http://127.0.0.1:14702

	at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:722)
	at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$get$8(HtmlUnitDriver.java:687)
	at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$runAsync$0(HtmlUnitDriver.java:429)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: No script object associated with the Page. class: 'com.gargoylesoftware.htmlunit.html.HtmlPage' url: 'http://127.0.0.1:14702/page_with_frames.html' content: <!DOCTYPE html>
<html lang="en">
<head>
  <title>Test::frames</title>
  <meta charset="UTF-8">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<frameset rows="80,*" cols="*">
  <frame src="hello_world.txt" name="topFrame" id="top-frame" scrolling="no" noresize>
  <frameset cols="300,*">
    <frame src="page_with_dynamic_select.html" name="leftFrame" scrolling="no" noresize>
    <frame src="page_with_jquery.html" name="mainFrame">
    <frame src="page_with_parent_frame.html" name="parentFrame">
  </frameset>
</frameset>
</html>

	at com.gargoylesoftware.htmlunit.html.DomNode.getScriptableObject(DomNode.java:922)
	at com.gargoylesoftware.htmlunit.javascript.host.event.Event.<init>(Event.java:215)
	at com.gargoylesoftware.htmlunit.javascript.host.event.BeforeUnloadEvent.<init>(BeforeUnloadEvent.java:69)
	at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1217)
	at com.gargoylesoftware.htmlunit.html.HtmlPage.isOnbeforeunloadAccepted(HtmlPage.java:1291)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:371)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:315)
	at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:704)
	... 5 more

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
rbricommented, Oct 16, 2020

@asolntsev @BASSEMALMAHW have published a new snapshot build - can you please test if your problem is gone with this snapshot

0reactions
rbricommented, Oct 16, 2020

sounds reasonable - thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

[HtmlUnit] [ htmlunit-Bugs-2833433 ] "No script object" error ...
IllegalStateException : No script object associated with the Page at com.gargoylesoftware.htmlunit.html.DomNode.getScriptObject(DomNode.java:847)
Read more >
How to overcome an HTMLUnit ScriptException?
In my case it works well and script is performing immediately (when I used only webClient.getOptions().setThrowExceptionOnScriptError(false) ...
Read more >
IllegalStateException (Java Platform SE 7 ) - Oracle Help Center
Constructs an IllegalStateException with no detail message. A detail message is a String that describes this particular exception.
Read more >
Solution for java.lang.illegalstateexception in Selenium ...
The root cause of java.lang.illegalstateexception is we have not specified the path of the driver with the system property.
Read more >
IllegalStateException - Android Developers
On this page ... Indicates whether some other object is "equal to" this one. ... Note that the detail message associated with cause...
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