I'm trying to set a local storage key and value using OpenQA Selenium and Chrome. I thought this would be fairly trivial but I can't seem to get it to work. I'm quite new to C# so I maybe missing something. Anyway I have this function:
public static void SetMockData() { OpenQA.Selenium.Remote.RemoteWebStorage storage = new OpenQA.Selenium.Remote.RemoteWebStorage((OpenQA.Selenium.Remote.RemoteWebDriver)webDriver); storage.LocalStorage.SetItem("useTestData", "true"); }
I'm not sure if this is correct. Anyway when I run it I get the following exception:
System.NotImplementedException : unknown command: Cannot call non W3C standard command while in W3C mode
But I can't for the life of me turn off W3C. I can't see a chrome command argument to do it and I don't seem to have a way of adding a chrome option. There is an option in ChromeOptions called UseSpecCompliantProtocol
which doesn't seem to do anything when set to false or true.
How can I set local storage for selenium in this case?