Reputation: 521
I am looking at the selenium-webdriver API for .NET at http://selenium.googlecode.com/svn/trunk/docs/api/dotnet/index.html. For the arguments on IJavaScriptExecutor.ExecuteScript, it states that 'For a number, a Int64 is returned'. What do I need to do if I want to pass a decimal (in/out) with this method? The Java bindings, for example, currently support both decimal and non-decimal types.
Any help is appreciated.
Thanks, Vaibhav
Since I can't answer my own question, I am editing the question. I ran the following code to do test the argument types that can be passed to the ExcecuteScript method.
try
{
IWebDriver driver = new InternetExplorerDriver();
string script = "return arguments[0];";
double d = 15.009;
float f = 13.2f;
decimal dec = 0.2m;
int i = 8;
object value = ((IJavaScriptExecutor)driver).ExecuteScript(script, new object[] { dec });
driver.Close();
driver.Quit();
}
catch(Exception ex)
{}
The above code throws an exception 'Argument is of an illegal type 0.2 Parameter name: arg'. But the other values (double/float/int) can be passed and the return value is same as passed. The double should serve my purpose for now. I was worried that the webdriver would convert my double into Int64 when passed through that method. I think the documentation needs to be revised.
Thanks, Vaibhav
Upvotes: 2
Views: 2799
Reputation: 13665
So the solution would be to use float
instead of decimal
.
Then cast float
parameters to object
and cast returned object
to float
.
Upvotes: 0