I'm trying to automate some stuff which involves browsing to a https url. I'm using py-appscript with Safari on Mac OS X. But when Safari navigates to the https URL, since I have a self-signed certificate, it throws up a popup window which asks you to accept it to continue. I could not figure out a way to do this. Sure using signed certificates will solve the problem but I was curious if it is even po开发者_如何学编程ssible via appscript to accept or click on the popup dialog boxes on Safari?
Well, answering my own question. Hopefully it'll be useful to someone...
from appscript import *
app(u'Safari').activate()
title = app(u'Safari').do_JavaScript(u'document.title', in_=app.documents[1])
app(u'Safari').documents[1].URL.set(u'https://localhost/')
app(u'System Events').application_processes[u'Safari'].windows[title].sheets[1].groups[2].UI_elements[u'Continue'].click()
精彩评论