[python]代码库
# coding:utf-8
from selenium import webdriver
import time
def login(driver, user, password):
'''登录github'''
driver.get("https://github.com/login")
driver.implicitly_wait(10)
driver.find_element_by_id("login_field").send_keys(user)
driver.find_element_by_id("password").send_keys(password)
driver.find_element_by_name("commit").click()
def logout(driver):
'''退出github'''
time.sleep(3)
driver.find_element_by_css_selector(".HeaderNavlink.name.mt-1").click()
time.sleep(1)
# 点sign out
driver.find_element_by_css_selector(".dropdown-item.dropdown-signout").click()
driver.quit()
if __name__ == "__main__":
driver = webdriver.Firefox()
login(driver, "youruser", "yourpsw")
print("hello world!")
logout(driver)