MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / Storage

Class Storage

java/src/org/openqa/selenium/bidi/module/Storage.java:36–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34import org.openqa.selenium.json.JsonInput;
35
36public class Storage {
37 private static final Json JSON = new Json();
38
39 private final BiDi bidi;
40
41 private static final Function<JsonInput, GetCookiesResult> getCookiesResultMapper =
42 jsonInput -> jsonInput.readNonNull(GetCookiesResult.class);
43
44 private static final Function<JsonInput, PartitionKey> partitionKeyResultMapper =
45 jsonInput -> {
46 Map<String, String> partitionKey = jsonInput.readMapElement("partitionKey");
47 try (StringReader reader = new StringReader(JSON.toJson(partitionKey));
48 JsonInput input = JSON.newInput(reader)) {
49 return input.readNonNull(PartitionKey.class);
50 }
51 };
52
53 public Storage(WebDriver driver) {
54 Require.nonNull("WebDriver", driver);
55
56 if (!(driver instanceof HasBiDi)) {
57 throw new IllegalArgumentException("WebDriver instance must support BiDi protocol");
58 }
59
60 this.bidi = ((HasBiDi) driver).getBiDi();
61 }
62
63 public GetCookiesResult getCookies(GetCookiesParameters params) {
64 return this.bidi.send(
65 new Command<>("storage.getCookies", params.toMap(), getCookiesResultMapper));
66 }
67
68 public PartitionKey setCookie(SetCookieParameters params) {
69 return this.bidi.send(
70 new Command<>("storage.setCookie", params.toMap(), partitionKeyResultMapper));
71 }
72
73 public PartitionKey deleteCookies(DeleteCookiesParameters params) {
74 return this.bidi.send(
75 new Command<>("storage.deleteCookies", params.toMap(), partitionKeyResultMapper));
76 }
77}

Callers

nothing calls this directly

Calls 4

readNonNullMethod · 0.80
readMapElementMethod · 0.80
toJsonMethod · 0.65
newInputMethod · 0.45

Tested by

no test coverage detected