Skip to content

Instantly share code, notes, and snippets.

@jarmo
Created Nov 4, 2010
Embed
What would you like to do?
>>prompt("enter!")
"info"
>>prompt("cancel!")
null
>>confirm("yes!")
true
>>confirm("no!")
false
# don't return anything for alert
browser.execute_script("window.alert = function() {}")
# return some string for prompt to simulate user entering it
browser.execute_script("window.prompt = function() {return 'my name'}")
# return null for prompt to simulate clicking Cancel
browser.execute_script("window.prompt = function() {return null}")
# return true for confirm to simulate clicking OK
browser.execute_script("window.confirm = function() {return true}")
# return false for confirm to simulate clicking Cancel
browser.execute_script("window.confirm = function() {return false}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment