Morgan Allen Morgan Allen - 4 months ago 25
Python Question

Passing a value into a python variable via Splinter

I'm looking at a web page and making a yes/no decision. I'm trying to create a prompt that will allow me to pass the "yes" / "no" to a python variable via Splinter.

1.) Page loads

2.) Execute something like

browser.execute_script("window.prompt()")
with a yes/ no to a variable

3.) Some business logic is done based on that variable

ie -

data = browser.execute_script("window.prompt()")
if data == 'yes':
print('the value is good')
else:
print('the value is bad')


Is there a good way to go about doing this?

Answer

Is there a good way to go about doing this?

No. Use Python's input (or raw_input if using Python 2), or get that value as a command line argument.

Comments