I have a boolean JavaScript variable named foo
that I would like to change the value of from true to false. The variable has global scope.
In Selenium, how can I change the value of this variable?
(The variable, hidden to the user, disables a CPU-intensive feature that causes Selenium to choke.)
You didn't specify a language and Selenium tool, so...
Java + Selenium WebDriver
// assuming JS is enabled for this driver instance
((JavascriptExecutor)driver).executeScript("window.foo = false;");
Java + Selenium RC
selenium.getEval("window.foo = false;")
C# + Selenium WebDriver
((IJavaScriptExecutor)driver).ExecuteScript("window.foo = false;");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With