Skip to content

Instantly share code, notes, and snippets.

@kiorky
Last active December 16, 2015 22:39
Show Gist options
  • Save kiorky/5508527 to your computer and use it in GitHub Desktop.
Save kiorky/5508527 to your computer and use it in GitHub Desktop.
for spynner #35
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__docformat__ = 'restructuredtext en'
import spynner
import os
import sys
class CSCCAuthenticationError(Exception):pass
timeout=60
class test(object):
user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31"
cco_password = os.environ.get('CISCO_PASS', 'foo')
cco_username = os.environ.get('CISCO_USER', 'bar')
auth_attempts = 1000
def test(self):
self.cscc_url = (
'https://apps.cisco.com/CustAdv/ServiceSales/smcam/'
'requestStatusDispatch.do?methodName=onDashboardAction')
br = self.browser = spynner.Browser(
ignore_ssl_errors=False,
user_agent=self.user_agent,
debug_level=spynner.DEBUG,
debug_stream=sys.stderr)
br.show()
br.load('http://www.cisco.com')
br.click_link('.ft-login a', 10)
#try:
# self.browser.load(self.cscc_url, load_timeout=timeout)
#except spynner.SpynnerTimeout:
# raise
attempts = 0
while self.browser.url.find('sso.cisco.com') != -1:
if attempts >= self.auth_attempts:
raise CSCCAuthenticationError
attempts += 1
if self.cco_username:
self.browser.fill('input[name=userid]', self.cco_username)
if self.cco_password:
self.browser.fill('input[name=password]', self.cco_password)
self.browser.submit('input[id=login-button][name=login-button]')
import pdb;pdb.set_trace() ## Breakpoint ##
assert self.browser.url == self.cscc_url
def main():
test().test()
if __name__ == '__main__':
main()
# vim:set et sts=4 ts=4 tw=80:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment