Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I'm brand new to selenium webdriver for python, and I've run into a problem I can't solve. I've searched for an answer, but didn't see anything. I apologize if I've missed it.

We had the following command in a selenium IDE script:

getEval | window.$("#DestList option").attr('selected','selected')

In my webdriver python script, I made that command look like this:

driver.execute_script("return window.$("#DestList option").attr('selected','selected')")

When I run the python script, whatever line follows the execute_script line gets an error:

SyntaxError: invalid syntax

Which leads me to believe something is missing from my execute_script command. Can someone tell me what might be missing or where I'm going wrong?

thanks in advance for your help and patience.

Ed

share|improve this question

1 Answer 1

up vote 1 down vote accepted

It is just about the quotes inside the script, fix it (tested, worked for me):

driver.execute_script("return window.$('#DestList option').attr('selected','selected')")
share|improve this answer
    
Thanks so much alecxe! That fixed my problem. I really appreciate the help. – edszr Jan 21 at 0:06

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.