edszr
edszr

Reputation: 63

My execute_script command in selenium webdriver for python is causing an error on the following line

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

Upvotes: 0

Views: 1123

Answers (1)

alecxe
alecxe

Reputation: 473863

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')")

Upvotes: 1

Related Questions