参考:
下载chromedriver地址:http://chromedriver.storage.googleapis.com/index.html或者http://npm.taobao.org/mirrors/chromedriver/
配置chromedriver:https://jingyan.baidu.com/article/f7ff0bfcdd89ed2e27bb1379.html
我的chrome版本:78.0.3904.97(64位)可以使用win32的chromedriver
chromedriver对照表:https://blog.csdn.net/BinGISer/article/details/88559532
selenium使用的基本指导:https://www.jianshu.com/p/87aeb3341a83
selenium处理弹出框:https://www.cnblogs.com/simran/p/9240917.html
selenium自动登录百度:https://jingyan.baidu.com/article/1612d500e8be56e20e1eee83.html
win8+pycharm+python3.6
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time
# 我写的方法:登录百度
url = "https://www.baidu.com/"
# url = "https://music.163.com/#/my/m/music/playlist?id=809646899"
automation = webdriver.Chrome()
automation.get(url)
automation.find_element_by_xpath('//*[@id="u1"]/a[7]').click()
ele_id = "TANGRAM__PSP_10__footerULoginBtn"
param = (By.ID, ele_id)
WebDriverWait(automation,10).until(EC.visibility_of_element_located(param))
automation.find_element_by_id(ele_id).click()
ele_id_password = "TANGRAM__PSP_10__userName"
param_password = (By.ID, ele_id_password)
WebDriverWait(automation,10).until(EC.visibility_of_element_located(param_password))
input_password = automation.find_element_by_id(ele_id_password)
input_password.send_keys('xxx')
ele_id_password = "TANGRAM__PSP_10__password"
# param_password = (By.ID, ele_id_password)
# WebDriverWait(automation,10).until(EC.visibility_of_element_located(param_password))
input_password = automation.find_element_by_id(ele_id_password)
input_password.send_keys('xxx')
ele_id_submit = "TANGRAM__PSP_10__submit"
# param_submit = (By.ID, ele_id_submit)
# WebDriverWait(automation,10).until(EC.visibility_of_element_located(param_submit))
automation.find_element_by_id(ele_id_submit).click()
# time.sleep(10)
# automation.quit()
time.sleep(60)
ele_class = "s_ipt"
input_content = automation.find_element_by_class_name(ele_class)
input_content.send_keys('华为mate30')
input_content.send_keys(Keys.ENTER)