司格特 发表于 2018-7-3 14:53:14

selenium3 qq邮箱上传下载

实现功能:qq邮箱上传附件定位元素:此为input标签,可以直接用send_keys方法,进入到邮箱页面后,首先click'写信',driver需切换到frame通过name定位:'UploadFile'代码如下:# _*_ coding:utf-8 _*_
from selenium importwebdriver
from selenium.webdriver.common.action_chains importActionChains
from pywinauto.application import Application
importtime,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('')//文件路径

页: [1]
查看完整版本: selenium3 qq邮箱上传下载