Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a function called 'checkdata(code)' in javascript, which, as you can see, takes an argument called 'code' to run and returns a 15-char string.

So, I found out (and tested) how to call no-argument functions in javascript, but my problem is that when I call checkdata(code), I always get a 'none' return value. This is what I'm doing so far:

wd = webdriver.Firefox()
wd.get('My Webpage')
a = wd.execute_script("return checkdata()", code)  //Code is a local variable
                                                   //from my python script
print a

I'm making this, since I read it on an unofficial selenium documentation and here: link

But, as I said before, I just keep getting none printed.

How can I call my function passing that parameter?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Build the string

a = wd.execute_script("return checkdata('" + code + "');")
share|improve this answer
    
Ah, got it working thanks to you!, here is what my code looks like: a = local.execute_script(' return checkdata(\"'+code+'\")') print a Thanks for the help! –  Jose_Sunstrider Dec 30 '12 at 5:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.