selenium3 qq邮箱上传下载
实现功能:qq邮箱上传附件
定位元素:此为input标签,可以直接用send_keys方法,进入到邮箱页面后,首先click'写信',driver需切换到frame
通过name定位:'UploadFile'代码如下:
# _*_ coding:utf-8 _*_ from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from pywinauto.application import Application import time,os driver = webdriver.Chrome('C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe') driver.maximize_window() driver.get('https://mail.qq.com/cgi-bin/loginpage') time.sleep(5) driver.switch_to.frame("login_frame") driver.find_element_by_name('u').send_keys('2574674466') driver.find_element_by_name('p').send_keys('') driver.find_element_by_id('login_button').click() time.sleep(3) driver.find_element_by_id('composebtn').click() time.sleep(3) driver.switch_to.frame("mainFrame") driver.find_element_by_id('subject').send_keys('test') time.sleep(3) driver.find_element_by_name('UploadFile').).send_keys('')//文件路径
欢迎加入交流群:Selenium学习群: 628908894