首页 > 代码库 > 工作小脚本--发送公告

工作小脚本--发送公告

from selenium import webdriver
from time import sleep


driver = webdriver.Firefox()
driver.get("xxx")
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(100):
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[1]/a‘).click()
#继续切换表单
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(‘/html/body/div/div/div[2]/div[1]/div[2]/div/ul/li/span[3]‘).click()
sleep(0.2)
#发送内容
driver.find_element_by_xpath(‘//*[@id="notice-text"]‘).send_keys(i)
sleep(0.2)
#点击发送
driver.find_element_by_id(‘save-btn‘).click()
sleep(0.5)
#点击提示框确定
driver.find_element_by_xpath(‘/html/body/div[3]/div[7]/div/button‘).click()
sleep(1)
driver.refresh()


工作小脚本--发送公告