chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument("--window-size=1280,720")
chrome_options.add_argument("--start-maximized")
dr = webdriver.Chrome(chrome_options=chrome_options)
dr.get('http://www.baidu.com') # 此处地址随便写,只是示例
dr.implicitly_wait(5)
dr.find_element_by_id('phone').send_keys('admin')
dr.find_element_by_id('password').send_keys('pass')
dr.find_element_by_id('loginButton').click()
dr.save_screenshot('screen_shoot2.png') # 好奇怪,无头模式下不执行登录操作。但是加上这一行就会执行了