|
55 | 55 | import org.openqa.selenium.HasCapabilities;
|
56 | 56 | import org.openqa.selenium.HasDownloads;
|
57 | 57 | import org.openqa.selenium.ImmutableCapabilities;
|
58 |
| -import org.openqa.selenium.JavascriptException; |
59 | 58 | import org.openqa.selenium.JavascriptExecutor;
|
60 | 59 | import org.openqa.selenium.MutableCapabilities;
|
61 | 60 | import org.openqa.selenium.NoAlertPresentException;
|
|
66 | 65 | import org.openqa.selenium.Platform;
|
67 | 66 | import org.openqa.selenium.Point;
|
68 | 67 | import org.openqa.selenium.PrintsPage;
|
69 |
| -import org.openqa.selenium.ScriptKey; |
70 | 68 | import org.openqa.selenium.SearchContext;
|
71 | 69 | import org.openqa.selenium.SessionNotCreatedException;
|
72 | 70 | import org.openqa.selenium.TakesScreenshot;
|
73 |
| -import org.openqa.selenium.UnpinnedScriptKey; |
74 | 71 | import org.openqa.selenium.WebDriver;
|
75 | 72 | import org.openqa.selenium.WebDriverException;
|
76 | 73 | import org.openqa.selenium.WebElement;
|
|
86 | 83 | import org.openqa.selenium.internal.Debug;
|
87 | 84 | import org.openqa.selenium.internal.Require;
|
88 | 85 | import org.openqa.selenium.io.Zip;
|
89 |
| -import org.openqa.selenium.json.TypeToken; |
90 | 86 | import org.openqa.selenium.logging.LocalLogs;
|
91 | 87 | import org.openqa.selenium.logging.LoggingHandler;
|
92 | 88 | import org.openqa.selenium.logging.Logs;
|
@@ -480,86 +476,6 @@ public Object executeAsyncScript(String script, Object... args) {
|
480 | 476 | return execute(DriverCommand.EXECUTE_ASYNC_SCRIPT(script, convertedArgs)).getValue();
|
481 | 477 | }
|
482 | 478 |
|
483 |
| - @Override |
484 |
| - public ScriptKey pin(String script) { |
485 |
| - UnpinnedScriptKey key = (UnpinnedScriptKey) JavascriptExecutor.super.pin(script); |
486 |
| - String browserName = getCapabilities().getBrowserName().toLowerCase(); |
487 |
| - if ((browserName.equals("chrome") |
488 |
| - || browserName.equals("msedge") |
489 |
| - || browserName.equals("microsoftedge")) |
490 |
| - && this instanceof HasDevTools) { |
491 |
| - |
492 |
| - ((HasDevTools) this) |
493 |
| - .maybeGetDevTools() |
494 |
| - .ifPresent( |
495 |
| - devTools -> { |
496 |
| - devTools.createSessionIfThereIsNotOne(); |
497 |
| - devTools.send( |
498 |
| - new org.openqa.selenium.devtools.Command<>("Page.enable", ImmutableMap.of())); |
499 |
| - devTools.send( |
500 |
| - new org.openqa.selenium.devtools.Command<>( |
501 |
| - "Runtime.evaluate", ImmutableMap.of("expression", key.creationScript()))); |
502 |
| - Map<String, Object> result = |
503 |
| - devTools.send( |
504 |
| - new org.openqa.selenium.devtools.Command<>( |
505 |
| - "Page.addScriptToEvaluateOnNewDocument", |
506 |
| - ImmutableMap.of("source", key.creationScript()), |
507 |
| - new TypeToken<Map<String, Object>>() {}.getType())); |
508 |
| - key.setScriptId((String) result.get("identifier")); |
509 |
| - }); |
510 |
| - } |
511 |
| - return key; |
512 |
| - } |
513 |
| - |
514 |
| - @Override |
515 |
| - public void unpin(ScriptKey scriptKey) { |
516 |
| - UnpinnedScriptKey key = (UnpinnedScriptKey) scriptKey; |
517 |
| - |
518 |
| - JavascriptExecutor.super.unpin(key); |
519 |
| - |
520 |
| - String browserName = getCapabilities().getBrowserName().toLowerCase(); |
521 |
| - if ((browserName.equals("chrome") |
522 |
| - || browserName.equals("msedge") |
523 |
| - || browserName.equals("microsoftedge")) |
524 |
| - && this instanceof HasDevTools) { |
525 |
| - ((HasDevTools) this) |
526 |
| - .maybeGetDevTools() |
527 |
| - .ifPresent( |
528 |
| - devTools -> { |
529 |
| - devTools.send( |
530 |
| - new org.openqa.selenium.devtools.Command<>("Page.enable", ImmutableMap.of())); |
531 |
| - devTools.send( |
532 |
| - new org.openqa.selenium.devtools.Command<>( |
533 |
| - "Runtime.evaluate", ImmutableMap.of("expression", key.removalScript()))); |
534 |
| - devTools.send( |
535 |
| - new org.openqa.selenium.devtools.Command<>( |
536 |
| - "Page.removeScriptToEvaluateOnLoad", |
537 |
| - ImmutableMap.of("identifier", key.getScriptId()))); |
538 |
| - }); |
539 |
| - } |
540 |
| - } |
541 |
| - |
542 |
| - @Override |
543 |
| - public Object executeScript(ScriptKey key, Object... args) { |
544 |
| - Require.stateCondition( |
545 |
| - key instanceof UnpinnedScriptKey, "Script key should have been generated by this driver"); |
546 |
| - |
547 |
| - if (!getPinnedScripts().contains(key)) { |
548 |
| - throw new JavascriptException("Script is unpinned"); |
549 |
| - } |
550 |
| - |
551 |
| - String browserName = getCapabilities().getBrowserName().toLowerCase(); |
552 |
| - |
553 |
| - if ((browserName.equals("chrome") |
554 |
| - || browserName.equals("msedge") |
555 |
| - || browserName.equals("microsoftedge")) |
556 |
| - && this instanceof HasDevTools) { |
557 |
| - return executeScript(((UnpinnedScriptKey) key).executionScript(), args); |
558 |
| - } |
559 |
| - |
560 |
| - return executeScript(((UnpinnedScriptKey) key).getScript(), args); |
561 |
| - } |
562 |
| - |
563 | 479 | @Override
|
564 | 480 | public TargetLocator switchTo() {
|
565 | 481 | return new RemoteTargetLocator();
|
|
0 commit comments