1 # -*- coding:utf-8 -*- 2 3 from selenium import webdriver 4 5 browser = webdriver.Firefox() 6 7 browser.get('http://www.51testing.com') 8 print browser.title 9 print browser.page_source 10 browser.find_element_by_id('username').send_keys('username') 11 browser.find_element_by_id('userpass').send_keys('passworld') 12 13 browser.find_element_by_id('dologin').click() 14 15 input_seccode = raw_input('请输入验证码,并按 Enter 键:') 16 browser.find_element_by_id('xspace-seccode').send_keys(input_seccode) 17 18 browser.find_element_by_id('securitysubmit').click() 19 browser.quit()