htmlunit: IllegalStateException: No script object associated with the Page
I 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
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (9 by maintainers)
Commits related to this issue
- make sure setting the enclosedPage of an window makes only a complete initialized page visible to the outside (#68) — committed to HtmlUnit/htmlunit by rbri 4 years ago
- make sure setting the enclosedPage of an window makes only a complete initialized page visible to the outside (#68) — committed to HtmlUnit/htmlunit by rbri 4 years ago
@asolntsev @BASSEMALMAHW have published a new snapshot build - can you please test if your problem is gone with this snapshot