Skip to content

Commit

Permalink
Fixing getLocalStorage and getSessionStorage to work on remote (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesamhamed authored Aug 4, 2023
1 parent bd9b843 commit 4aebad2
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.openqa.selenium.devtools.HasDevTools;
import org.openqa.selenium.devtools.NetworkInterceptor;
import org.openqa.selenium.html5.LocalStorage;
import org.openqa.selenium.html5.SessionStorage;
import org.openqa.selenium.html5.WebStorage;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.http.HttpRequest;
Expand Down Expand Up @@ -553,11 +554,19 @@ public FluentBrowserActions setWindowSize(int width, int height) {
}

public LocalStorage getLocalStorage() {
return ((WebStorage) DriverFactoryHelper.getDriver().get()).getLocalStorage();
if(SHAFT.Properties.platform.executionAddress().equals("local")){
return ((WebStorage) DriverFactoryHelper.getDriver().get()).getLocalStorage();
}else{
return (LocalStorage)((JavascriptExecutor) DriverFactoryHelper.getDriver().get()).executeScript("return window.localStorage;");
}
}

public LocalStorage getSessionStorage() {
return (LocalStorage) ((WebStorage) DriverFactoryHelper.getDriver().get()).getSessionStorage();
public SessionStorage getSessionStorage() {
if(SHAFT.Properties.platform.executionAddress().equals("local")){
return ((WebStorage) DriverFactoryHelper.getDriver().get()).getSessionStorage();
}else{
return (SessionStorage) ((JavascriptExecutor) DriverFactoryHelper.getDriver().get()).executeScript("return window.sessionStorage;");
}
}

public FluentBrowserActions mock(Predicate<HttpRequest> requestPredicate, HttpResponse mockedResponse) {
Expand Down

0 comments on commit 4aebad2

Please sign in to comment.