from selenium import webdriver import time driver=webdriver.Firefox() driver.get('http://127.0.0.1/zentao/user-login.html') time.sleep(3) #调用jquery,在浏览器编辑的 jq=''' $('#account').val('admin'); $('[name=password]').val('123456'); $('[id=submit]').click() ''' driver.execute_script(jq) time.sleep(4) #driver.find_element_by_link_text('退出').click() driver.find_element_by_xpath(".//*[@id='topnav']/a[1]").click()