selenium3 qq邮箱上传下载

实现功能:qq邮箱上传附件

定位元素:此为input标签,可以直接用send_keys方法,进入到邮箱页面后,首先click'写信',driver需切换到frame

selenium3 qq邮箱上传下载

通过name定位:'UploadFile'代码如下:

# _*_ coding:utf-8 _*_from selenium import  webdriverfrom selenium.webdriver.common.action_chains import  ActionChainsfrom pywinauto.application import Applicationimport  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('')//文件路径

 

上一篇:Selenium3自动化测试【18】XPath定位元素(2)


下一篇:Python3+Selenium3+Unittest+ddt+Requests 接口自动化测试框架