IllegalStateException: No script object associated with the Page
See original GitHub issueI guess it happens when
- A page with frames is being parsed, and
- One of frames changes URL
- 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:
- Created 4 years ago
- Comments:18 (9 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@asolntsev @BASSEMALMAHW have published a new snapshot build - can you please test if your problem is gone with this snapshot
sounds reasonable - thanks