Skip to content

Commit

Permalink
fix JavaScriptHandling initialization scripts removing feature after …
Browse files Browse the repository at this point in the history
  • Loading branch information
mialeska committed Feb 28, 2023
1 parent f50ce60 commit 3b008e9
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.openqa.selenium.devtools.idealized.Events;
import org.openqa.selenium.devtools.idealized.Javascript;
import org.openqa.selenium.devtools.idealized.ScriptId;
import org.openqa.selenium.devtools.idealized.target.model.SessionID;
import org.openqa.selenium.devtools.v85.page.Page;
import org.openqa.selenium.devtools.v85.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v85.runtime.Runtime;
Expand Down Expand Up @@ -111,7 +112,9 @@ private void removeInitializationScriptCore(InitializationScript script) {
final Field pinnedScripts = Javascript.class.getDeclaredField("pinnedScripts");
pinnedScripts.setAccessible(true);
//noinspection unchecked
((Map<String, ScriptId>)pinnedScripts.get(engine)).remove(script.getScriptSource());
((Map<SessionID, Map<String, ScriptId>>)pinnedScripts.get(engine))
.get(tools.getDevToolsSession().getCdpSession())
.remove(script.getScriptSource());
pinnedScripts.setAccessible(false);
} catch (ReflectiveOperationException e) {
AqualityServices.getLogger().fatal("Error while removing initialization script", e);
Expand Down

0 comments on commit 3b008e9

Please sign in to comment.