Answer the question
In order to leave comments, you need to log in
How to pass variable to escaped js string?
I'm trying to display an alert with the value of my variable in selenium, but I don't quite understand how to pass it to an escaped string, I will be grateful for any help
value = "bar"
driver.execute_script('''
foo = value;
alert(foo);
''')
Answer the question
In order to leave comments, you need to log in
value = 'bar'
driver.execute_script("foo = \'" + value + "\'; alert(foo);");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question