首页 > 代码库 > 工作小脚本--发送闻思

工作小脚本--发送闻思

from selenium import webdriver
from time import sleep


driver = webdriver.Firefox()
driver.get("xxx")
#浏览器最大化
driver.maximize_window()
driver.find_element_by_name(‘account‘).send_keys(‘xxx‘)
driver.find_element_by_name(‘pwd‘).send_keys(‘xxx‘)
sleep(5)
driver.find_element_by_id(‘login-btn‘).click()
sleep(2)



for i in range(200):
driver.find_element_by_link_text(‘事务管理‘).click()
sleep(0.2)
# 消息推送
driver.find_element_by_xpath(‘/html/body/div/nav/div[2]/div[1]/ul/li[5]/ul/li/a‘).click()
sleep(0.2)

xp = driver.find_element_by_xpath("//div[@id=‘content-main‘]/iframe")
driver.switch_to.frame(xp)
sleep(0.2)
#点击闻思
driver.find_element_by_xpath(‘/html/body/div/div/div/ul/li[3]/a‘).click()
sleep(0.5)
xp = driver.find_element_by_xpath("//iframe[@id=‘control-frame‘]")
driver.switch_to.frame(xp)
#新建闻思
driver.find_element_by_id(‘btn-add‘).click()
sleep(1)
#输入标题
driver.find_element_by_xpath(‘//*[@id="title"]‘).send_keys(i)
#定位到下一个iframe
xp = driver.find_element_by_xpath("//div[@id=‘edui1_iframeholder‘]/iframe")
driver.switch_to.frame(xp)
sleep(0.5)
#输入内容
driver.find_element_by_tag_name(‘body‘).send_keys(i)
sleep(0.5)
#返回到上一个表单
driver.switch_to.parent_frame()
#点击保存
sleep(0.5)
driver.find_element_by_xpath(‘//*[@id="save-btn"]‘).click()
sleep(2.5)
#点击发布
driver.find_element_by_xpath(‘//*[@id="send-btn"]‘).click()
sleep(0.5)

driver.refresh()


工作小脚本--发送闻思