-
Notifications
You must be signed in to change notification settings - Fork 10
Other Extensions
Lukasz Rajchel edited this page Jan 22, 2018
·
3 revisions
This method allows to execute JavaScript scripts more easily.
driver.ExecuteScript("myJavaScriptMethod()");If you want to get the value out of the script use the generic override of this method.
var result = driver.ExecuteScript<string>("return myJavaScriptMethod()");Since Selenium supports only several types of results returned from JavaScript you need to make sure that the generic type passed to the ExecuteScript method is in sync with what Selenium support.
For an HTML element, this method returns a IWebElement. For a number, a long is returned. For a boolean, a bool is returned. For all other cases a string is returned. For an array, we check the first element, and attempt to return a List of that type, following the rules above. Nested lists are not supported.
Using the library
Extending the library