selenium 调用方法
#coding:utf-8 from selenium import webdriver url = "http://demo.testfire.net" chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu') driver = webdriver.Chrome(chrome_options=chrome_options,executable_path='/Users/xxxx/driver/chromedriver') driver.get('http://demo.testfire.net') driver.find_element_by_xpath('//*[@id="_ctl0__ctl0_LoginLink"]').click() driver.find_element_by_xpath('//*[@id="uid"]').clear() driver.find_element_by_xpath('//*[@id="uid"]').send_keys('admin') driver.find_element_by_xpath('//*[@id="passw"]').send_keys('admin') driver.find_element_by_xpath('//*[@id="login"]/table/tbody/tr[3]/td[2]/input').click() print driver.current_url