Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Testing sessionStorage using JS executor
//Set item value
public void setItem(String itemName, String itemValue) {
((JavascriptExecutor) driver).executeScript("window.sessionstorage.setitem(itemName, itemValue)");
//Get item value
public String getItem(String itemValue) {
return (String) ((JavascriptExecutor) driver).executeScript(String.format(
"return window.sessionstorage.getItem('%s');", itemValue));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment