org.openqa.selenium.devtools.v130.database.Database Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenium-devtools-v130 Show documentation
Show all versions of selenium-devtools-v130 Show documentation
Selenium automates browsers. That's it! What you do with that power is entirely up to you.
The newest version!
package org.openqa.selenium.devtools.v130.database;
import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import java.util.Map;
import java.util.LinkedHashMap;
import org.openqa.selenium.json.JsonInput;
@Beta()
public class Database {
/**
* Disables database tracking, prevents database events from being sent to the client.
*/
public static Command disable() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Database.disable", Map.copyOf(params));
}
/**
* Enables database tracking, database events will now be delivered to the client.
*/
public static Command enable() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Database.enable", Map.copyOf(params));
}
public static class ExecuteSQLResponse {
private final java.util.Optional> columnNames;
private final java.util.Optional> values;
private final java.util.Optional sqlError;
public ExecuteSQLResponse(java.util.Optional> columnNames, java.util.Optional> values, java.util.Optional sqlError) {
this.columnNames = columnNames;
this.values = values;
this.sqlError = sqlError;
}
public java.util.Optional> getColumnNames() {
return columnNames;
}
public java.util.Optional> getValues() {
return values;
}
public java.util.Optional getSqlError() {
return sqlError;
}
private static ExecuteSQLResponse fromJson(JsonInput input) {
java.util.Optional> columnNames = java.util.Optional.empty();
java.util.Optional> values = java.util.Optional.empty();
java.util.Optional sqlError = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "columnNames":
columnNames = java.util.Optional.ofNullable(input.readArray(java.lang.String.class));
break;
case "values":
values = java.util.Optional.ofNullable(input.readArray(java.lang.Object.class));
break;
case "sqlError":
sqlError = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v130.database.model.Error.class));
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new ExecuteSQLResponse(columnNames, values, sqlError);
}
}
public static Command executeSQL(org.openqa.selenium.devtools.v130.database.model.DatabaseId databaseId, java.lang.String query) {
java.util.Objects.requireNonNull(databaseId, "databaseId is required");
java.util.Objects.requireNonNull(query, "query is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("databaseId", databaseId);
params.put("query", query);
return new Command<>("Database.executeSQL", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v130.database.Database.ExecuteSQLResponse.class));
}
public static Command> getDatabaseTableNames(org.openqa.selenium.devtools.v130.database.model.DatabaseId databaseId) {
java.util.Objects.requireNonNull(databaseId, "databaseId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("databaseId", databaseId);
return new Command<>("Database.getDatabaseTableNames", Map.copyOf(params), ConverterFunctions.map("tableNames", input -> input.readArray(java.lang.String.class)));
}
public static Event addDatabase() {
return new Event<>("Database.addDatabase", ConverterFunctions.map("database", org.openqa.selenium.devtools.v130.database.model.Database.class));
}
}